コード例 #1
0
ファイル: main.cpp プロジェクト: ravenwolfthorn/AIE_Work
//draw each frame of the game
void drawGame()
{
	static char s_cOutScore1[15] = {'\n'};
	static char s_cOutScore2[15] = {'\n'};

	//DrawSprite(g_uiBgImage);

	DrawSprite(g_ball.iSprite);
	DrawSprite(g_player1.iSprite);
	DrawSprite(g_player2.iSprite);

	sprintf(s_cOutScore1, "Player 1: %d", g_iPlayer1Score);
	sprintf(s_cOutScore2, "Player 2: %d", g_iPlayer2Score);
	//draw the scores
	DrawString(s_cOutScore1, 50, 50, SColour(255,0,0,255));
	DrawString(s_cOutScore2, 1000, 50, SColour(0,255,0,255));

	if(g_iFrameCounter >= 20 && g_bPowerUpVis != true )
	{
		g_bPowerUpVis = true;
	}

	if( g_bPowerUpVis = true )
	{
		if( updatePowerUp(g_powerUp,g_ball,g_player1,g_bPowerUpVis) )
		{
			DrawSprite(g_powerUp.iSprite);
		}
	}

	if(g_bGameOver == true)
	{
		DrawString("Game Over", SCREEN_X / 2, 300);

		char acScore[15];
		int iY = 350;
		for(int i = 0; i < 5; i++)
		{
			if(g_aiHighScores[i] != 0 )
			{
				sprintf(acScore, "player %d: %d", i+1, g_aiHighScores[i]);
				DrawString(acScore, SCREEN_X / 2, iY);
				iY += 30;
			}
		}

		vector2 v2BallPosition = {SCREEN_X / 2, 300};
		g_ball.v2Position = v2BallPosition;
		DestroySprite(g_ball.iSprite);
		DrawSprite(g_ball.iSprite);
		g_ball.v2Speed.fX = 0;
		g_ball.v2Speed.fY = 0;

	}

	
}
コード例 #2
0
ファイル: PlayState.cpp プロジェクト: sphippen/Galaxulon
void PlayState::update()
{
	// Shake the background up and down when bomb is used
	if(bombAnimation)
	{
		bombAnimationCount++;
		bombShakeCounter++;
		// Up
		if(bombShakeCounter < 5)
		{
			starsBG_Pos.y -= 2;
		}
		// Down + Down
		else if(bombShakeCounter < 15)
		{
			starsBG_Pos.y += 2;
		}
		// Up
		else if(bombShakeCounter < 20)
		{
			starsBG_Pos.y -= 2;
		}
		// Reset
		else
		{
			bombShakeCounter = 0;
			--starsBG_Pos.y;
		}

		if(bombAnimationCount == BOMB_ANIMATION_LENGTH)
		{
			bombAnimationCount = 0;
			bombAnimation = false;
		}
	}

	// Move BG
	++bgMoveCounter;

	if(bgMoveCounter > 2)
	{
		++starsBG_Pos.x;
		bgMoveCounter = 0;
	}

	REG_BG0VOFS = starsBG_Pos.y;
	REG_BG0HOFS = starsBG_Pos.x;

	updateText();

	// Update the stage
	currentStage->update();

	// Checks for button pushes and updates accordingly
	checkInput();

	updatePlayer();
	
	// Udates the PowerUp and checks for collisions
	updatePowerUp();

	// Updates all of the enemies and has them fire.
	updateEnemies();

	// Updates all of the bullets and checks for collisions
	updateBullets();
}