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.
GameEngine.h
00001 #ifndef GAMEENGINE_H 00002 #define GAMEENGINE_H 00003 00004 // Included Headers ------------------------------------------------------------ 00005 #include "HUD.h" 00006 #include "Menu.h" 00007 #include "FXOS8700CQ.h" 00008 #include "SDFileSystem.h" 00009 #include "SavedGames.h" 00010 #include "Settings.h" 00011 #include "Sounds.h" 00012 #include "HighScore.h" 00013 #include "PlayEngine.h" 00014 00015 /** GameEngine class 00016 * @brief Runs the different parts of the menu and playable part of game 00017 * @author Benjamin Evans, University of Leeds 00018 * @date April 2020 00019 */ 00020 class GameEngine:private PlayEngine { 00021 public: 00022 /** Constructor */ 00023 GameEngine(); 00024 00025 /** Destructor */ 00026 ~GameEngine(); 00027 00028 /** Initialises GameEngine */ 00029 void init(); 00030 00031 /** Switch statement to run different menu options */ 00032 void game_select_part(); 00033 00034 private: 00035 // Function prototypes ----------------------------------------------------- 00036 00037 // Menu Control 00038 /** Runs the menu */ 00039 void run_menu(); 00040 00041 /** Draws loading screen */ 00042 void loading_screen(); 00043 00044 /** Selects the different parts of the playable game like the pause 00045 * screen and save screen 00046 */ 00047 void play_select(); 00048 00049 // Menu Play 00050 /** Runs the play game */ 00051 void run_play(); 00052 00053 /** Initialises the play part of the game*/ 00054 void play_init(); 00055 00056 /** Only runs movement when the spaceship is not destroyed */ 00057 void spaceship_not_detroyed(); 00058 00059 /** Main gameplay loop that runs playable part of game */ 00060 void gameplay_loop(); 00061 00062 /** Draws the game over screen*/ 00063 void draw_game_over_screen(); 00064 00065 /** Runs the paused screen */ 00066 void run_paused_game(); 00067 00068 /** Draws the pause screen*/ 00069 void draw_pause_screen(); 00070 00071 /** Runs saved games screen */ 00072 void run_saved_games(); 00073 00074 /** Time-triggered interrupt to wake MCU from sleep */ 00075 void lcd_frame_time_isr(); 00076 00077 /** Plays the music if its turned on */ 00078 void play_music(); 00079 00080 /** Stops the music if its turned off */ 00081 void stop_music(); 00082 00083 // Menu Setting 00084 /** Runs settings screen*/ 00085 void run_settings(); 00086 00087 // Menu Saved Games 00088 /** Initialises the play part of the game and sets the variables to 00089 * saved values 00090 */ 00091 void saved_games_overide_init(); 00092 00093 /** Runs save a game screen */ 00094 void run_save_a_game(); 00095 00096 // Menu High Score 00097 /** Runs high score screen */ 00098 void run_highscore(); 00099 00100 /** Calculates if the current end game score is a new high score and 00101 * saves it if it is 00102 * @return new_high_score @detials bool true if there is new high score 00103 */ 00104 bool calculate_new_score(); 00105 00106 // Variables --------------------------------------------------------------- 00107 00108 // Menu Control 00109 /** The part of the menu that is currently selected and in*/ 00110 MenuParts current_menu_part_; 00111 00112 /** Volatile flag for ISR */ 00113 volatile int lcd_frame_time_flag_; 00114 00115 /** Flag to exit the play part of the game */ 00116 bool exit_flag_; 00117 00118 /** Flag to run the save game screen */ 00119 bool run_save_a_game_flag_; 00120 00121 /** Counter for pause screen so pause button doesn’t double press */ 00122 int paused_counter_; 00123 00124 /** Hold on or off depending if music is set on or off */ 00125 MusicParts music_fx_; 00126 00127 /** Paused button pressed flag for pausing during the game */ 00128 bool paused_button_pressed_; 00129 00130 /** Flag for turning the music on and off in the settings*/ 00131 bool music_flag_; 00132 00133 // Objects ----------------------------------------------------------------- 00134 00135 /** Define HUD object */ 00136 HUD hud; 00137 00138 /** Define Menu object */ 00139 Menu menu; 00140 00141 /** Define Setting object */ 00142 Settings setting; 00143 00144 /** Define Ticker object for lcd framerate */ 00145 Ticker ticker; 00146 00147 /** Define SavedGames object */ 00148 SavedGames saved; 00149 00150 /** Define HighScore object */ 00151 HighScore h_score; 00152 }; 00153 00154 #endif
Generated on Fri Aug 5 2022 06:55:07 by
1.7.2