Initial publish

Dependencies:   mbed

Fork of el17dg by Dmitrijs Griskovs

Committer:
Noximilien
Date:
Tue Apr 23 18:18:57 2019 +0000
Revision:
31:becb8f6bf7b7
Parent:
30:d454d0cb72bc
Child:
32:5403bb974294
Have changed comments structure as well as the content. Finished intro music. Have cleaned a code in some places to make it readable.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Noximilien 3:10918b0f7a7d 1 #ifndef GAME_H
Noximilien 3:10918b0f7a7d 2 #define GAME_H
Noximilien 3:10918b0f7a7d 3
Noximilien 31:becb8f6bf7b7 4 /**
Noximilien 31:becb8f6bf7b7 5 * GameGlobals Class
Noximilien 31:becb8f6bf7b7 6 * @brief Globals that different places in code can modify
Noximilien 31:becb8f6bf7b7 7 * @author Dmitrijs Griskovs
Noximilien 31:becb8f6bf7b7 8 * @date 22/04/2019
Noximilien 31:becb8f6bf7b7 9 */
Noximilien 31:becb8f6bf7b7 10 class GameGlobals {
Noximilien 31:becb8f6bf7b7 11 public:
Noximilien 31:becb8f6bf7b7 12 static int game_score;
Noximilien 31:becb8f6bf7b7 13 static int score_count_for_difficulty;
Noximilien 31:becb8f6bf7b7 14 static int player_lifes;
Noximilien 31:becb8f6bf7b7 15 static int high_score;
Noximilien 31:becb8f6bf7b7 16 static bool is_shield_on;
Noximilien 31:becb8f6bf7b7 17 };
Noximilien 24:0570cb4b92d7 18
Noximilien 31:becb8f6bf7b7 19 /**
Noximilien 31:becb8f6bf7b7 20 * Game Class
Noximilien 31:becb8f6bf7b7 21 * @brief Stores general game logic.
Noximilien 29:579e00b7f118 22 * @author Dmitrijs Griskovs
Noximilien 29:579e00b7f118 23 * @date 15/04/2019
Noximilien 29:579e00b7f118 24 */
Noximilien 4:02c63aaa2df9 25 class Game{
Noximilien 4:02c63aaa2df9 26 public:
Noximilien 31:becb8f6bf7b7 27 /**
Noximilien 31:becb8f6bf7b7 28 * Constructor.
Noximilien 31:becb8f6bf7b7 29 * @brief It's crucial to init game_over to true, so it calls
Noximilien 31:becb8f6bf7b7 30 * startNewGame on the first update. */
Noximilien 31:becb8f6bf7b7 31 Game() : game_over(true) { }
Noximilien 31:becb8f6bf7b7 32
Noximilien 31:becb8f6bf7b7 33 /**
Noximilien 31:becb8f6bf7b7 34 * @brief The main game function where all the gameplay and rendering happens.
Noximilien 31:becb8f6bf7b7 35 * @details This is the main function of game.cpp, where the actual gameplay happens.
Noximilien 31:becb8f6bf7b7 36 * Here all other functions are activeated, and when the player dies, it
Noximilien 31:becb8f6bf7b7 37 * returns back to main menu "main.cpp" it also draws all sprites in the game.
Noximilien 31:becb8f6bf7b7 38 * @returns bool want_to_pause, when "START" button is pressed.
Noximilien 31:becb8f6bf7b7 39 */
Noximilien 27:f05f4e738ba9 40 bool updateAndDraw();
Noximilien 31:becb8f6bf7b7 41
Noximilien 31:becb8f6bf7b7 42 /**
Noximilien 31:becb8f6bf7b7 43 * @brief Resets all the in game variable when new game begins.
Noximilien 31:becb8f6bf7b7 44 * @details This function resets all the values to their intial states when
Noximilien 31:becb8f6bf7b7 45 * the game is first began when the player dies and wants to restart the game.
Noximilien 31:becb8f6bf7b7 46 * It does not reset the values when the game is paused.
Noximilien 31:becb8f6bf7b7 47 */
Noximilien 21:0eb394495b8a 48 void startNewGame();
Noximilien 31:becb8f6bf7b7 49
Noximilien 31:becb8f6bf7b7 50 /**
Noximilien 31:becb8f6bf7b7 51 * @brief Check whether the button R was pressed or not to turn ON/OFF the shield.
Noximilien 31:becb8f6bf7b7 52 * @details When the button R is pressed it sets bool "is_shield_active" to its opposite
Noximilien 31:becb8f6bf7b7 53 * value. If the shield is active then, a ship with force shield sprite is drawn and
Noximilien 31:becb8f6bf7b7 54 * the player's ability to shoot deactivates.
Noximilien 31:becb8f6bf7b7 55 */
Noximilien 30:d454d0cb72bc 56 bool forceShildActivate();
Noximilien 4:02c63aaa2df9 57 private:
Noximilien 27:f05f4e738ba9 58 bool checkForGameOver();
Noximilien 21:0eb394495b8a 59 void collideEnemiesAndBlasts();
Noximilien 21:0eb394495b8a 60 void collideEnemiesBlastsAndPlayer();
Noximilien 23:240bc00ef25b 61 void collideEnemiesAndPlayer();
Noximilien 26:676874c42883 62 void starsSpawnDelay();
Noximilien 26:676874c42883 63 void increaseGameDifficultyAndEnemySpawnDelay();
Noximilien 23:240bc00ef25b 64 void gameOver();
Noximilien 28:35af3843de8f 65 void drawGameOver();
Noximilien 29:579e00b7f118 66 void ledsGameOver();
Noximilien 29:579e00b7f118 67 void musicGameOver();
Noximilien 29:579e00b7f118 68 void printMusicCountersTest();
Noximilien 29:579e00b7f118 69 void lowFrequencyPartMusic();
Noximilien 29:579e00b7f118 70 void highFrequencyPartMusic();
Noximilien 30:d454d0cb72bc 71 bool returnToMenu();
Noximilien 31:becb8f6bf7b7 72
Noximilien 31:becb8f6bf7b7 73 bool game_over;
Noximilien 31:becb8f6bf7b7 74 // The speed of every counter is 1Hz
Noximilien 31:becb8f6bf7b7 75 int low_frequency_music_counter;
Noximilien 31:becb8f6bf7b7 76 int high_frequency_music_counter;
Noximilien 31:becb8f6bf7b7 77 int enemy_ship_delay_counter;
Noximilien 31:becb8f6bf7b7 78
Noximilien 31:becb8f6bf7b7 79 int enemy_ship_delay_max;
Noximilien 31:becb8f6bf7b7 80 bool led_state;
Noximilien 3:10918b0f7a7d 81 };
Noximilien 3:10918b0f7a7d 82
Noximilien 3:10918b0f7a7d 83
Noximilien 3:10918b0f7a7d 84 #endif