示例#1
0
文件: chopper.c 项目: Rockbox/rockbox
static int chopUpdateTerrainRecycling(struct CTerrain *ter)
{
    int i=1;
    int iNewNodePos,g,v;
    while(i < ter->iNodesCount)
    {

        if( iCameraPosX > ter->mNodes[i].x)
        {

            chopTerrainNodeDeleteAndShift(ter,i);

            iNewNodePos = ter->iLastNodePlacedPosX + 50;
            g = iScreenY - 10;

            v = 3*iPlayerSpeedX;
            if(v>50)
                v=50;
            if(iCurrLevelMode == LEVEL_MODE_STEEP)
                v*=5;

            chopAddTerrainNode(ter,iNewNodePos,g - iR(-v,v));
        }

        i++;

    }

    return 1;
}
示例#2
0
文件: chopper.c 项目: Rockbox/rockbox
static void chopper_load(bool newgame)
{

    int i;
    int g;

    if (newgame) {
        iScreenX = LCD_WIDTH * SIZE;
        iScreenY = LCD_HEIGHT * SIZE;
        blockh = iScreenY / 5;
        blockw = iScreenX / 20;
        iPlayerAlive = 1;
        iCurrLevelMode = iLevelMode;
        score = 0;
    }
    iRotorOffset = 0;
    iPlayerPosX = 60;
    iPlayerPosY = (iScreenY * 4) / 10;
    iLastBlockPlacedPosX = 0;
    iGravityTimerCountdown = 2;
    chopCounter = 0;
    iPlayerSpeedX = 3;
    iPlayerSpeedY = 0;
    iCameraPosX = 30;

    for (i=0; i < NUMBER_OF_PARTICLES; i++)
        mParticles[i].bIsActive = 0;

    for (i=0; i < NUMBER_OF_BLOCKS; i++)
        mBlocks[i].bIsActive = 0;

    g = iScreenY - 10;
    chopClearTerrain(&mGround);

    for (i=0; i < MAX_TERRAIN_NODES; i++)
        chopAddTerrainNode(&mGround,i * 30,g - iR(0,20));

    if (chopUpdateTerrainRecycling(&mGround) == 1)
        /* mirror the sky if we've changed the ground */
        chopCopyTerrain(&mGround, &mRoof, 0, - ( (iScreenY * 3) / 4));

    if (iCurrLevelMode == LEVEL_MODE_NORMAL)
        /* make it a bit more exciting, cause it's easy terrain... */
        iPlayerSpeedX *= 2;
}
示例#3
0
int chopUpdateTerrainRecycling(CTerrain *ter)
{
	int i=1;
	int ret = 0;
	int iNewNodePos,g,v;
	while(i < ter->iNodesCount)
	{
		
		if( iCameraPosX > ter->mNodes[i].x)
		{
//			int x = ter->mNodes[i].x;
			//it's off the screen
			chopTerrainNodeDeleteAndShift(ter,i);
			
			
			
			iNewNodePos = ter->iLastNodePlacedPosX + 50; //magic number
			g = iScreenY - 10;
			
			v = 10;
			if(iLevelMode == LEVEL_MODE_STEEP)
				v*=5;
				
			chopAddTerrainNode(ter,iNewNodePos,g - iR(-v,v));
			
			ret=1;
			
			
		}

		i++;
		
	}

	return ret;
}
示例#4
0
void new_chopper_window(void)
{

	int i,g;
	i=0;
	chopGC = pz_get_gc(1);       /* Get the graphics context */
	GrGetScreenInfo(&screen_info); /* Get screen info */
	
	/* Open the window: */
	chopWindow = pz_new_window (0,
					21,
					screen_info.cols,
					screen_info.rows - 21, /* Height of screen - header  */
					chopDrawScene,
					chopHandleEvent);
					
	chopBuffer = GrNewPixmap(screen_info.cols,
							(screen_info.rows - (HEADER_TOPLINE + 1)),
							NULL);
	
					
	iScreenX = screen_info.cols;
	iScreenY = screen_info.rows - 21;
	
	/* Select the types of events you need for your window: */
	GrSelectEvents (chopWindow,
			GR_EVENT_MASK_KEY_DOWN
			| GR_EVENT_MASK_TIMER | GR_EVENT_MASK_KEY_UP);
	
	/* Display the window: */
	GrMapWindow (chopWindow);
	
	/* Create the timer used for animating your application: */
	chopTimer = GrCreateTimer (chopWindow,
					75); /* Timer interval, millisecs */
					
	/*chopDrawScene();*/
	
	iRotorOffset = 0;
	//chopAddBlock(100,100,20,20);
	
		
	iPlayerPosX = 60;
	iPlayerPosY = iScreenY * 0.2;
	
	iLastBlockPlacedPosX = 0;
	iGravityTimerCountdown = 2;
	
	iPlayerAlive = 1;
	
	chopCounter = 0;
	
	
	
	while(i < NUMBER_OF_BLOCKS)
	{
		mBlocks[i].bIsActive = 0;
		i++;
	}
	
	g = iScreenY - 10;
	
	chopClearTerrain(&mGround);
	
	i=0;
	
	
	while(i < MAX_TERRAIN_NODES) //we could add less, probably.
	{
		chopAddTerrainNode(&mGround,i * 30,g - iR(0,20));
		
		i++;
	}
	
	if(chopUpdateTerrainRecycling(&mGround)==1)
		chopCopyTerrain(&mGround,&mRoof,0,-( iScreenY * 0.75)); //mirror the sky if we've changed the ground
	
	iLevelMode = iR(1,2);
	
	iPlayerSpeedX = 4;
	iPlayerSpeedY = 0;

	
	if(iLevelMode == LEVEL_MODE_NORMAL)
		iPlayerSpeedX*=2; //make it a bit more exciting, cause it's easy terrain...
	//printf("level mode: %d",iLevelMode);
	
	bWaitingToStart = 1;
}