Drawing the HUD, home, and level-up screens
All the code in the following three code blocks goes in the drawing phase of our game loop. All we need to do is draw the appropriate Text
objects during the appropriate states, in the draw section of the main game loop.
In the PLAYING
state, add the following highlighted code:
//Draw the crosshair window.draw(spriteCrosshair); // Switch to the HUD view window.setView(hudView); // Draw all the HUD elements window.draw(spriteAmmoIcon); window.draw(ammoText); window.draw(scoreText); window.draw(hiScoreText); window.draw(healthBar); window.draw(waveNumberText); window.draw(zombiesRemainingText); } if (state == State::LEVELING_UP) { }
The vital thing...