Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of el17dg by
Diff: game/hud.h
- Revision:
- 31:becb8f6bf7b7
- Parent:
- 30:d454d0cb72bc
- Child:
- 32:5403bb974294
--- a/game/hud.h Tue Apr 16 21:16:33 2019 +0000 +++ b/game/hud.h Tue Apr 23 18:18:57 2019 +0000 @@ -3,43 +3,53 @@ #include "game.h" -/**Hud Class - * @brief A library for describing the player's heads up display(hud). +/** + * Hud Class + * @brief Renders interface elemets such as score and lifes * @author Dmitrijs Griskovs * @date 15/04/2019 */ class Hud { public: -/** @brief Draws an in-game score on the screen during the gameplay. */ + + Hud() { resetRedLed(); } + + void resetRedLed() { + red_led_flashing = 0; + red_led_state = false; + } + + /** @brief Draws an in-game score on the screen during the gameplay. */ void drawScore(){ char buffer[16]; - sprintf(buffer," Score: %i",game_score); + sprintf(buffer," Score: %i", GameGlobals::game_score); lcd.printString(buffer,0,0); } -/**@brief Displays the highest score reached in the main menu. */ + + /**@brief Displays the highest score reached in the main menu. */ void drawHighScore(){ - if (high_score < game_score){ - high_score = game_score; + if (GameGlobals::high_score < GameGlobals::game_score){ + GameGlobals::high_score = GameGlobals::game_score; } - char buffer[16]; - sprintf(buffer,"High Score %i",high_score); - lcd.printString(buffer,0,0); + char buffer[16]; + sprintf(buffer,"High Score %i", GameGlobals::high_score); + lcd.printString(buffer,0,0); } -/** @brief Mointors, updates and shows the player's lives. - * @details Checks the palyer's life value and lights the LEDs on/off accordingly to - * how many lifes are left. green = 3, yellow = 2 and red = 1. - */ + /** + * @brief Display life counter using LEDs. + * @details Checks the palyer's life value and lights the LEDs on/off + * accordingly to how many lifes are left. green = 3, yellow = 2 and red = 1. + */ void displayLifes(){ - //printf("displayLifes:: %i\n", player_lifes); - if (player_lifes == 3){ + if (GameGlobals::player_lifes == 3){ playerHasThreeLives(); } - else if (player_lifes == 2){ + else if (GameGlobals::player_lifes == 2){ playerHasTwoLives(); } - else if (player_lifes == 1){ + else if (GameGlobals::player_lifes == 1){ playerHasOneLife(); } else { @@ -74,6 +84,8 @@ } red_led_flashing += 1; } + int red_led_flashing; + bool red_led_state; }; #endif \ No newline at end of file