Ejemplo n.º 1
0
//Process
bool cGame::Process() {
	bool res=true;
	
	// Process Input
	if(keys[27])	res=false;	
	
	if (!playingAmbient) {
		sounds.PlayAmbient(SOUND_AMBIENT1);
		playingAmbient = true;
	}

	if(!Scene.IsInitialized) {
		ProcessStartScreenKeys();
	} else if (InitialZoomDistance == 0 && !IsGameover && !IsLevelUp) {
		ProcessGameKeys();
		ProcessBullets();
		Enemies.Logic(DILATATION,(TERRAIN_SIZE-2)*DILATATION);
		CollidesEnemies();
	}

	if(WireframeRendering) ProcessWireframeModeKeys();

	return res;
}
Ejemplo n.º 2
0
void RenderGame()
{
	bool wasInvisible = player ? player->position.x < -50 : true;
	CanUpdate = GameOver == false && IsGamePaused == false;
	backbuffer->Clear( 0 );

	//Draw the background
	charmap->DrawCopy(backbuffer);


	//Update all entities and the background (horizontal scrolling)
	if( tick % 24 == 23 && charmap->x > -3228 && CanUpdate)
	{
		charmap->x-= ScrollingSpeed;

		if( player )
		{
			Point p2 = player->position;
			p2.x += 30;
			Point p1 = p2;
			p1.y -= 5;
			p2.y += 5;
			if( charmap->IsCollediable(p1) || charmap->IsCollediable(p2) )
			{
				player->position.x-= ScrollingSpeed;
			}
		}		

		ProcessEnemies2();
	}

	//Update the player
	if( player && player->IsAlive )
	{
		if( CanUpdate )
			player->Update();
		player->Draw(backbuffer);
	}
	/*
	else
	{
		GameOver = true;
	}
	*/
	
	//Update enemies
	ProcessEnemies();
	//Update bullets
	ProcessBullets();

	//Draw beamer-strength bar
	DrawGauge(150,260, beamstrength, 0xFFFF);
	//Draw health bar
	DrawGauge(350,260, gfx_var_health, 0x0ADF);
	//Draw scores

	char buffer[30];
	sprintf_s(buffer,"%d", score);
	font->Print(backbuffer, buffer, 140 - font->Width(buffer),253);

	
	//If we get stuck behind a tile we're gameover
	if( wasInvisible && player && player->position.x < -50 ) 
	{
		player->LeaveViewport();
	}
	
	//Draw some fonts in special occasions
	if( GameOver == true )
	{
		gameOverGraphics->AddAreaTo(0,0,gameOverGraphics->GetWidth() - 1, gameOverGraphics->GetHeight() - 1, backbuffer, (SCRWIDTH - gameOverGraphics->GetWidth()  )/ 2,(SCRHEIGHT - gameOverGraphics->GetHeight() )/ 2);
	}
	//If you die while the your ship is leaving the stage you won't be winning so much afterall.
	else if( GameWon == true )
	{
		gameWonGraphics->AddAreaTo(0,0,gameWonGraphics->GetWidth() - 1, gameWonGraphics->GetHeight() - 1, backbuffer, (SCRWIDTH - gameWonGraphics->GetWidth()  )/ 2,(SCRHEIGHT - gameWonGraphics->GetHeight() )/ 2);
	}
	else if( IsGamePaused == true )
	{
		gamePausedGraphics->AddAreaTo(0,0,gamePausedGraphics->GetWidth() - 1, gamePausedGraphics->GetHeight() - 1, backbuffer, (SCRWIDTH - gamePausedGraphics->GetWidth()  )/ 2,(SCRHEIGHT - gamePausedGraphics->GetHeight() )/ 2);
	}

	backbuffer->CopyTo(surface,0,0);

}