Game over
As the saying goes, all good things must come to an end. If the player doesn't meet the pickup threshold, the game will end, and the game over screen will be displayed. The player can choose to replay the game or exit.
The game over screen
Our last screen is the game over screen. By now, the process should be second nature, so let's try an abbreviated approach:
Declare a pointer to the screen:
Sprite* gameOverScreen;
Instantiate the sprite in
LoadTextures
:gameOverScreen = new Sprite(1); gameOverScreen->SetFrameSize(800.0f, 600.0f); gameOverScreen->SetNumberOfFrames(1); gameOverScreen->AddTexture("resources/gameover.png", false); gameOverScreen->IsActive(true); gameOverScreen->IsVisible(true);
Change the
GS_GameOver
case in theUpdate
function to look like the following code:case GameState::GS_GameOver: { gameOverScreen->Update(p_deltaTime); replayButton->IsActive(true); replayButton->Update(p_deltaTime); exitButton->IsActive(true); exitButton->...