예제 #1
0
void gameLoop() {
	
	--pipe.x;
	if(pipe.x < 232 && pipe.x > 160) {
		initPipe();
	}
	movePipe();
	
	//Scroll ground
	if(WX_REG == 0)
		WX_REG = 7;
	else
		--WX_REG;
	
	if(updateBird() != 0) {
		//Kill bird
		flash_frames = 0;
		bird_flag = FALSE;
		
		set_sprite_prop(0, S_FLIPY);
		set_sprite_prop(1, S_FLIPY);
		
		gameState = GAME_STATE_DEAD;
	}
	
	if(!pipe.counted && pipe.x+24 < bird_x) {
		pipe.counted = TRUE;
		if(score != 99) {
			++score;
			updateScore();
		}
	}
	
	moveBird();
}
예제 #2
0
void Game::update(sf::Time elapsedTime)
{
    float timedelta = elapsedTime.asSeconds();

    if(!paused)
    {
        moveBird(timedelta);
        moveWalls(timedelta);
        checkBirdBounds();
        handleCollisions();
    }
}
예제 #3
0
void updateDeadBird() {
	
	if(!bird_flag) {
		bird_gravity.w += BIRD_GRAVITY_FORCE;
		bird_y += bird_gravity.b.h;
		
		if(bird_y >= 124 && bird_y < 210) {
			bird_y = 124;
			bird_flag = TRUE;
		}
	} else {
		++bird_frame_skip;
		if(bird_frame_skip >= 30) {
			resetGame();
		}
	}
	
	moveBird();
}
예제 #4
0
void Bird::showBird(ScreenSurface* screen, ImageSurface* image) {
    moveBird();
    screen->applySurface(*image, bird[frame/2].w, bird[frame/2].h, 
            bird[frame/2].x, bird[frame/2].y, 141,  200 + yFrame);
}