Пример #1
0
static int chopGameLoop(void)
{
    int move_button, ret;
    bool exit=false;
    bool showsplash=true;
    int end, i=0, bdelay=0, last_button=BUTTON_NONE;

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

    ret = chopMenu(0);
    if (ret != -1)
        return PLUGIN_OK;

    while (!exit) {

        end = *rb->current_tick + CYCLETIME;

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

        iRotorOffset = iR(-1,1);

        /* We need to have this here so particles move when we're dead */

        for (i=0; i < NUMBER_OF_PARTICLES; i++)
            if(mParticles[i].bIsActive == 1)
            {
                mParticles[i].iWorldX += mParticles[i].iSpeedX;
                mParticles[i].iWorldY += mParticles[i].iSpeedY;
            }

        /* Redraw the main window: */
        chopDrawScene();


        iGravityTimerCountdown--;

        if(iGravityTimerCountdown <= 0)
        {
            iGravityTimerCountdown = 3;
            chopAddParticle(iPlayerPosX, iPlayerPosY+5, 0, 0);
        }

        if(iCurrLevelMode == LEVEL_MODE_NORMAL)
            chopGenerateBlockIfNeeded();

        if (showsplash) {
            chopDrawScene();
            rb->splash(HZ, "Get Ready!");
            showsplash = false;
        }

        move_button=rb->button_status();
        if (rb->button_get(false) == QUIT) {
            ret = chopMenu(1);
            if (ret != -1)
                return PLUGIN_OK;
            showsplash = true;
            bdelay = 0;
            last_button = BUTTON_NONE;
            move_button = BUTTON_NONE;
        }

        switch (move_button) {
            case ACTION:
#ifdef ACTION2
            case ACTION2:
#endif
                if (last_button != ACTION
#ifdef ACTION2
                    && last_button != ACTION2
#endif
                   )
                    bdelay = -2;
                if (bdelay == 0)
                    iPlayerSpeedY = -3;
                break;

            default:
                if (last_button == ACTION
#ifdef ACTION2
                    || last_button == ACTION2
#endif
                   )
                    bdelay = 3;
                if (bdelay == 0)
                    iPlayerSpeedY = 4;

                if (rb->default_event_handler(move_button) == SYS_USB_CONNECTED)
                    return PLUGIN_USB_CONNECTED;
                break;
        }
        last_button = move_button;

        if (bdelay < 0) {
            iPlayerSpeedY = bdelay;
            bdelay++;
        } else if (bdelay > 0) {
            iPlayerSpeedY = bdelay;
            bdelay--;
        }

        iCameraPosX = iPlayerPosX - 25;
        iPlayerPosX += iPlayerSpeedX;
        iPlayerPosY += iPlayerSpeedY;

        chopCounter++;
        /* increase speed as we go along */
        if (chopCounter == 100){
            iPlayerSpeedX++;
            chopCounter=0;
        }

        if (iPlayerPosY > iScreenY-10 || iPlayerPosY < -5 ||
           chopPointInTerrain(&mGround, iPlayerPosX, iPlayerPosY + 10, 0) ||
           chopPointInTerrain(&mRoof, iPlayerPosX ,iPlayerPosY, 1))
        {
           chopKillPlayer();
           chopDrawScene();
           ret = chopMenu(0);
           if (ret != -1)
               return ret;
           showsplash = true;
        }

        for (i=0; i < NUMBER_OF_BLOCKS; i++)
            if(mBlocks[i].bIsActive == 1)
                if(chopBlockCollideWithPlayer(&mBlocks[i])) {
                    chopKillPlayer();
                    chopDrawScene();
                    ret = chopMenu(0);
                    if (ret != -1)
                        return ret;
                    showsplash = true;
                }

        if (TIME_BEFORE(*rb->current_tick, end))
            rb->sleep(end - *rb->current_tick); /* wait until time is over */
        else
            rb->yield();

    }
    return PLUGIN_OK;
}
Пример #2
0
static void chopGameLoop()
{
   int i=0;
	
	
	iRotorOffset = iR(-1,1);
	
	/* Redraw the main window: */
	chopDrawScene(); 
	
	if(bWaitingToStart == 1)return;
	
	//We need to have this here so particles move when we're dead
	while(i < NUMBER_OF_PARTICLES)
	{
		if(mParticles[i].bIsActive == 1)
		{
			mParticles[i].iWorldX += mParticles[i].iSpeedX;
			mParticles[i].iWorldY += mParticles[i].iSpeedY;
		}
		
		i++;
	}
	
	i=0;
	
	
	if(iPlayerAlive == 0)return;
	
	
	//increase score
	chopCounter++;
	
	iCameraPosX = iPlayerPosX - 25;
	iPlayerPosX+=iPlayerSpeedX;
	iPlayerPosY+=iPlayerSpeedY;
	
	iGravityTimerCountdown--;
	
	if(iGravityTimerCountdown <= 0)
	{
		//iPlayerSpeedY++;
		iGravityTimerCountdown = 3;
		
		chopAddParticle(iPlayerPosX,iPlayerPosY+5,0,0); //pretty hax putting this here :S
	}
	
	//cap player vel
	if(iPlayerSpeedY < -2)
		iPlayerSpeedY = -2;
	
	if(iLevelMode == LEVEL_MODE_NORMAL)
		chopGenerateBlockIfNeeded();
    
    
    
	if(bPlayerPressingUp == 1)
	{
		if(iPlayerSpeedY > 0)
			iPlayerSpeedY = 0;
		else
			iPlayerSpeedY-=2;
	}
	else
		iPlayerSpeedY++;

	
	//increase speed as we go along
	if(chopCounter % 300 == 0)
		iPlayerSpeedX++;
		
	
	if(iPlayerPosY > iScreenY-10 || iPlayerPosY < -5 ||  
	chopPointInTerrain(&mGround,iPlayerPosX,iPlayerPosY + 10,0) || chopPointInTerrain(&mRoof,iPlayerPosX,iPlayerPosY,1)
	)
	{
		chopKillPlayer();
	}
	
	
	while(i < NUMBER_OF_BLOCKS)
	{
		if(mBlocks[i].bIsActive == 1)
		{
			if(chopBlockCollideWithPlayer(&mBlocks[i]))
			{
				//pwned
				chopKillPlayer();
			}
		}
		
		i++;
	}
	
	if(chopUpdateTerrainRecycling(&mGround)==1)
		chopCopyTerrain(&mGround,&mRoof,0,-( iScreenY * 0.75)); //mirror the sky if we've changed the ground
}