Initial publish

Dependencies:   mbed

Fork of el17dg by Dmitrijs Griskovs

Committer:
Noximilien
Date:
Tue May 07 15:22:35 2019 +0000
Revision:
40:e3bbda7444fa
Parent:
37:6a2bf4488022
The Final, Submission Version. I have read and agreed to the academic integrity. SID:201160286

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 34:754915ce9de5 14 static int score_count_for_boss_mode;
Noximilien 31:becb8f6bf7b7 15 static int player_lifes;
Noximilien 31:becb8f6bf7b7 16 static int high_score;
Noximilien 31:becb8f6bf7b7 17 static bool is_shield_on;
Noximilien 31:becb8f6bf7b7 18 };
Noximilien 24:0570cb4b92d7 19
Noximilien 31:becb8f6bf7b7 20 /**
Noximilien 31:becb8f6bf7b7 21 * Game Class
Noximilien 31:becb8f6bf7b7 22 * @brief Stores general game logic.
Noximilien 29:579e00b7f118 23 * @author Dmitrijs Griskovs
Noximilien 29:579e00b7f118 24 * @date 15/04/2019
Noximilien 29:579e00b7f118 25 */
Noximilien 4:02c63aaa2df9 26 class Game{
Noximilien 4:02c63aaa2df9 27 public:
Noximilien 31:becb8f6bf7b7 28 /**
Noximilien 31:becb8f6bf7b7 29 * Constructor.
Noximilien 37:6a2bf4488022 30 * @brief It is crucial to init game_state to GameState_newgame, so it calls
Noximilien 37:6a2bf4488022 31 * startNewGame() on the first update.
Noximilien 32:5403bb974294 32 */
Noximilien 33:c623c6d5ed16 33 Game() : game_state(GameState_newgame) { }
Noximilien 31:becb8f6bf7b7 34
Noximilien 31:becb8f6bf7b7 35 /**
Noximilien 31:becb8f6bf7b7 36 * @brief The main game function where all the gameplay and rendering happens.
Noximilien 31:becb8f6bf7b7 37 * @details This is the main function of game.cpp, where the actual gameplay happens.
Noximilien 31:becb8f6bf7b7 38 * Here all other functions are activeated, and when the player dies, it
Noximilien 31:becb8f6bf7b7 39 * returns back to main menu "main.cpp" it also draws all sprites in the game.
Noximilien 31:becb8f6bf7b7 40 * @returns bool want_to_pause, when "START" button is pressed.
Noximilien 31:becb8f6bf7b7 41 */
Noximilien 27:f05f4e738ba9 42 bool updateAndDraw();
Noximilien 31:becb8f6bf7b7 43
Noximilien 31:becb8f6bf7b7 44 /**
Noximilien 31:becb8f6bf7b7 45 * @brief Resets all the in game variable when new game begins.
Noximilien 31:becb8f6bf7b7 46 * @details This function resets all the values to their intial states when
Noximilien 31:becb8f6bf7b7 47 * the game is first began when the player dies and wants to restart the game.
Noximilien 31:becb8f6bf7b7 48 * It does not reset the values when the game is paused.
Noximilien 31:becb8f6bf7b7 49 */
Noximilien 21:0eb394495b8a 50 void startNewGame();
Noximilien 31:becb8f6bf7b7 51
Noximilien 31:becb8f6bf7b7 52 /**
Noximilien 31:becb8f6bf7b7 53 * @brief Check whether the button R was pressed or not to turn ON/OFF the shield.
Noximilien 31:becb8f6bf7b7 54 * @details When the button R is pressed it sets bool "is_shield_active" to its opposite
Noximilien 31:becb8f6bf7b7 55 * value. If the shield is active then, a ship with force shield sprite is drawn and
Noximilien 31:becb8f6bf7b7 56 * the player's ability to shoot deactivates.
Noximilien 31:becb8f6bf7b7 57 */
Noximilien 30:d454d0cb72bc 58 bool forceShildActivate();
Noximilien 33:c623c6d5ed16 59
Noximilien 4:02c63aaa2df9 60 private:
Noximilien 34:754915ce9de5 61
Noximilien 33:c623c6d5ed16 62 void checkButtonToShoot();
Noximilien 27:f05f4e738ba9 63 bool checkForGameOver();
Noximilien 21:0eb394495b8a 64 void collideEnemiesAndBlasts();
Noximilien 21:0eb394495b8a 65 void collideEnemiesBlastsAndPlayer();
Noximilien 23:240bc00ef25b 66 void collideEnemiesAndPlayer();
Noximilien 33:c623c6d5ed16 67 void collideBossAndPlayerBlasts();
Noximilien 34:754915ce9de5 68 void collideBossBlastsAndPlayer();
Noximilien 26:676874c42883 69 void starsSpawnDelay();
Noximilien 26:676874c42883 70 void increaseGameDifficultyAndEnemySpawnDelay();
Noximilien 29:579e00b7f118 71 void printMusicCountersTest();
Noximilien 33:c623c6d5ed16 72 bool checkIfNeedsToReturnToMenu();
Noximilien 33:c623c6d5ed16 73 void updateAndDrawGameplay();
Noximilien 33:c623c6d5ed16 74 void updateAndDrawGameover();
Noximilien 33:c623c6d5ed16 75 void updateAndDrawBossCutscene();
Noximilien 33:c623c6d5ed16 76 void updateAndDrawBossGameplay();
Noximilien 33:c623c6d5ed16 77
Noximilien 31:becb8f6bf7b7 78 int enemy_ship_delay_counter;
Noximilien 31:becb8f6bf7b7 79 int enemy_ship_delay_max;
Noximilien 34:754915ce9de5 80 bool is_boss_active;
Noximilien 33:c623c6d5ed16 81
Noximilien 34:754915ce9de5 82
Noximilien 33:c623c6d5ed16 83 enum GameState {
Noximilien 33:c623c6d5ed16 84 GameState_newgame,
Noximilien 33:c623c6d5ed16 85 GameState_gameplay,
Noximilien 33:c623c6d5ed16 86 GameState_boss_cutscene,
Noximilien 33:c623c6d5ed16 87 GameState_boss_gameplay,
Noximilien 33:c623c6d5ed16 88 GameState_gameover
Noximilien 33:c623c6d5ed16 89 };
Noximilien 33:c623c6d5ed16 90 GameState game_state;
Noximilien 3:10918b0f7a7d 91 };
Noximilien 3:10918b0f7a7d 92
Noximilien 3:10918b0f7a7d 93
Noximilien 3:10918b0f7a7d 94 #endif