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.
MinerEngine.h
00001 #ifndef MINERENGINE_H 00002 #define MINERENGINE_H 00003 00004 #include "mbed.h" 00005 #include "N5110.h" 00006 #include "Gamepad.h" 00007 #include "Claw.h" 00008 #include "Winch.h" 00009 #include "Monster.h" 00010 #include "Gold.h" 00011 00012 // gap from edge of screen 00013 #define GAP 2 00014 00015 /** MinerEngine Class 00016 @brief Class for the structure of the game 00017 @brief It includes the control input, menu and other display parts(welcome,select,gameover,etc) 00018 @author Yufan Zhong, University of Leeds and SWJTU 00019 @date May 2020 00020 */ 00021 00022 class MinerEngine 00023 { 00024 00025 public: 00026 /** Constructor */ 00027 MinerEngine(); 00028 00029 /** Destructor */ 00030 ~MinerEngine(); 00031 00032 /** Initialise the components of the MinerEngine 00033 * @param winch_width - the width of the winch 00034 * @param winch_height - the height of the winch 00035 * @param gold_num - the gold number 00036 * @param monster_speed - the speed of monster 00037 */ 00038 void init(int winch_width,int winch_height,int gold_num,int monster_speed); 00039 00040 /** Initialise the unchanged parameter 00041 */ 00042 void init_unchanged_parameter(); 00043 00044 /** Switch the states 00045 * @param pad - Gamepad library 00046 * @param lcd - N5110 library 00047 */ 00048 void state_switch(Gamepad &pad, N5110 &lcd); 00049 00050 /** Get the select 00051 * @param pad - Gamepad library 00052 */ 00053 int get_select(Gamepad &pad); 00054 00055 /** Print the instruction 00056 * @param pad - Gamepad library 00057 * @param lcd - N5110 library 00058 */ 00059 void instruction(Gamepad &pad, N5110 &lcd); 00060 00061 /** Print the menu 00062 * @param pad - Gamepad library 00063 * @param lcd - N5110 library 00064 */ 00065 void menu(Gamepad &pad, N5110 &lcd); 00066 00067 /** Select the difficulties 00068 * @param pad - Gamepad library 00069 * @param lcd - N5110 library 00070 */ 00071 void options(Gamepad &pad, N5110 &lcd); 00072 00073 /** Run the game 00074 * @param pad - Gamepad library 00075 * @param lcd - N5110 library 00076 */ 00077 void game_run(Gamepad &pad, N5110 &lcd); 00078 00079 /** Draw all the components 00080 * @param lcd - N5110 library 00081 */ 00082 void draw(N5110 &lcd); 00083 00084 /** Read the gamepad input 00085 * @param pad - Gamepad library 00086 */ 00087 void read_input(Gamepad &pad); 00088 00089 /** Update the data 00090 * @param pad - Gamepad library 00091 */ 00092 void update(Gamepad &pad); 00093 00094 /** Print welcome component and wait for start 00095 * @param pad - Gamepad library 00096 * @param lcd - N5110 library 00097 */ 00098 void welcome(Gamepad &pad, N5110 &lcd); 00099 00100 /** Print game over on the screen 00101 * @param pad - Gamepad library 00102 * @param lcd - N5110 library 00103 */ 00104 void game_over(Gamepad &pad, N5110 &lcd); 00105 00106 /** Play the music 00107 * @param pad - Gamepad library 00108 */ 00109 void play_music(Gamepad &pad); 00110 00111 /** Roll up the picture 00112 * @param pad - Gamepad library 00113 * @param lcd - N5110 library 00114 */ 00115 void screen_rollup(Gamepad &pad, N5110 &lcd); 00116 00117 /** Print loading on the screen 00118 * @param pad - Gamepad library 00119 * @param lcd - N5110 library 00120 */ 00121 void loading(Gamepad &pad, N5110 &lcd); 00122 00123 /** Play the tunnel animation on the screen 00124 * @param pad - Gamepad library 00125 * @param lcd - N5110 library 00126 */ 00127 void tunnel(Gamepad &pad, N5110 &lcd); 00128 00129 /** Draw the tunnel 00130 * @param lcd - N5110 library 00131 */ 00132 void draw_tunnel(N5110 &lcd); 00133 00134 /** Draw the walking man 00135 * @param lcd - N5110 library 00136 */ 00137 void draw_man(N5110 &lcd); 00138 00139 /** Print message in the tunnel 00140 * @param pad - Gamepad library 00141 * @param lcd - N5110 library 00142 */ 00143 void tunnel_print(Gamepad &pad, N5110 &lcd); 00144 00145 00146 private: 00147 00148 /** Check if the gold has been lifted 00149 * @param pad - Gamepad library 00150 */ 00151 void check_gold_collision(Gamepad &pad); 00152 00153 /** Check if the monster collides with claw 00154 * @param pad - Gamepad library 00155 */ 00156 void check_monster_collision(Gamepad &pad); 00157 00158 /** Check if the claw gets the gold or the bottom 00159 * @param pad - Gamepad library 00160 */ 00161 void check_claw_collision(Gamepad &pad); 00162 00163 /** Check if gold reloading is needed 00164 */ 00165 void check_gold_reload(); 00166 00167 /** Print the score on the screen 00168 * @param lcd - N5110 library 00169 */ 00170 void print_scores(N5110 &lcd); 00171 00172 Winch _winch; 00173 Claw _claw; 00174 Gold _gold; 00175 Monster _monster; 00176 00177 int _winch_width; 00178 int _winch_height; 00179 int _gold_num; 00180 float _monster_speed; 00181 int _s; 00182 int _state; 00183 int _catching; 00184 int _claw_get; 00185 int _claw_speed; 00186 int _monster_collision; 00187 int _now_score; 00188 int _highest_score; 00189 int _gold_reached_num[9]; 00190 int _h; 00191 int _i; 00192 int _n; 00193 int _z; 00194 int _j; 00195 00196 Direction _d; 00197 float _mag; 00198 00199 }; 00200 00201 #endif
Generated on Sat Jul 16 2022 10:18:04 by
1.7.2