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.
Menu.h
00001 #ifndef MENU_H 00002 #define MENU_H 00003 00004 #include "mbed.h" 00005 #include "Gamepad.h" 00006 #include "N5110.h" 00007 #include "Graphics.h" 00008 #include "Mechanics.h" 00009 #include "Ghost.h" 00010 #include "Menu.h" 00011 #include "LEDs.h" 00012 #include <string> 00013 00014 #ifndef STRUCTS 00015 #define STRUCTS 00016 00017 //STRUCTS 00018 struct Point_2D { 00019 float x; 00020 float y; 00021 }; 00022 struct Line_2D { 00023 Point_2D from; 00024 Point_2D to; 00025 }; 00026 00027 struct Square_2D { 00028 Point_2D TL; 00029 Point_2D BR; 00030 }; 00031 struct Triangle_2D { 00032 Point_2D TL; 00033 Point_2D BR; 00034 int Type; 00035 }; 00036 00037 struct Sprite_2D { 00038 float x; 00039 float y; 00040 int type; 00041 }; 00042 00043 struct Map_Data { 00044 int number_of_track_lines; 00045 int number_of_dotted_lines; 00046 int number_of_sprites; 00047 int number_of_walls; 00048 int number_of_off_track_squares; 00049 int number_of_off_track_triangles; 00050 int number_of_out_of_bounds_squares; 00051 int number_of_out_of_bounds_triangles; 00052 int number_of_gates; 00053 int number_of_boost_plates; 00054 }; 00055 00056 struct Time { 00057 int mins; 00058 int secs; 00059 int milis; 00060 }; 00061 00062 struct Gyro_Data { 00063 float ax; 00064 float ay; 00065 float az; 00066 float mx; 00067 float my; 00068 float mz; 00069 }; 00070 00071 #endif 00072 00073 #ifndef ENUMS 00074 #define ENUMS 00075 enum track {Small, Medium, Large}; //Track Names 00076 enum cars {Basic, Offroad, Drifter, Sportscar, Racecar, Stupid}; //Car Names (Stupid is now the alien space ship) 00077 enum sprites {Flag, Helicopter, People_Standing_1, People_Standing_2, People_Cheering}; 00078 #endif 00079 00080 static int Setup_Ghost = 0; 00081 static int Setup_Map = Small; 00082 static int Setup_Laps = 3; 00083 static int Setup_Car = Basic; 00084 static bool Settings_LEDs = true; 00085 static bool Settings_Gyro = false; 00086 00087 enum Setup_States { 00088 GO_Main, 00089 Mode, 00090 Map, 00091 Laps, 00092 Car, 00093 Ghost_Warning, 00094 GO_Race, 00095 }; 00096 00097 struct Menu_Setup { 00098 int next_state[4]; 00099 }; 00100 00101 /** Menu Class 00102 * @brief Creates all game graphics. 00103 * @author Henry W Triff 00104 * @date Mar, 2020 00105 */ 00106 00107 class Menu 00108 { 00109 public: 00110 00111 /** Constructor */ 00112 Menu(); 00113 00114 /** Destructor */ 00115 ~Menu(); 00116 00117 /** Runs the main menu screen and the settings, credits and instructions menus. It also passes off to the game setup 00118 * @param LCD This is the N5110 class object (object) 00119 * @param Device This is the Gamepad class object (object) 00120 * @return True if the SD card needs to be formatted (bool) 00121 */ 00122 bool Main_Menu(N5110 &LCD, Gamepad &Device); 00123 00124 /** Runs the finite state machine for the game setup 00125 * @param LCD This is the N5110 class object (object) 00126 * @param Device This is the Gamepad class object (object) 00127 * @return True if the game should be started and false if returning to the main menu is required (bool) 00128 */ 00129 bool Game_Setup(N5110 &LCD, Gamepad &Device); 00130 00131 /** Returns the decided game mode 00132 * @return The selected game mode (int) 00133 */ 00134 int Get_Mode(); 00135 00136 /** Returns the decided game map 00137 * @return The selected game map (int) 00138 */ 00139 int Get_Map(); 00140 00141 /** Returns the number of laps decided 00142 * @return The selected number of laps (int) 00143 */ 00144 int Get_Laps(); 00145 00146 /** Returns the decided car 00147 * @return The selected car (int) 00148 */ 00149 int Get_Car(); 00150 00151 /** Returns the LED setting 00152 * @return The selected LED setting (bool) 00153 */ 00154 bool Get_Setting_LED(); 00155 00156 /** Returns the gyro control setting 00157 * @return The selected gyro control setting (bool) 00158 */ 00159 bool Get_Setting_Gyro(); 00160 00161 private: 00162 void Credits_Menu(N5110 &LCD, Gamepad &Device); 00163 bool Settings_Menu(N5110 &LCD, Gamepad &Device); 00164 bool Format_SD(N5110 &LCD, Gamepad &Device); 00165 void Instructions_Menu(N5110 &LCD, Gamepad &Device); 00166 int Setup_State_Mode(N5110 &LCD, Gamepad &Device); 00167 int Setup_State_Map(N5110 &LCD, Gamepad &Device); 00168 int Setup_State_Laps(N5110 &LCD, Gamepad &Device); 00169 int Setup_State_Car(N5110 &LCD, Gamepad &Device); 00170 int Setup_State_Ghost_Warning(N5110 &LCD, Gamepad &Device); 00171 }; 00172 00173 #endif
Generated on Wed Jul 20 2022 17:42:24 by
1.7.2