Ben Evans University Second Year Project. Game Called Defender.
Embed:
(wiki syntax)
Show/hide line numbers
PlayEngine.h
00001 #ifndef PLAYENGINE_H 00002 #define PLAYENGINE_H 00003 00004 // Included Headers ------------------------------------------------------------ 00005 #include "Spaceship.h" 00006 #include "Map.h" 00007 #include "Weapons.h" 00008 #include "Alien.h" 00009 #include "Explosion.h" 00010 #include "People.h" 00011 #include "Settings.h" 00012 #include <vector> 00013 00014 /** PlayEngine Class 00015 * @brief Runs the interactions between the different classes in the playable 00016 * part of the game. Also to break down the size of game engine class. Means I 00017 * can define the functions publicly to test them then inherit them privately. 00018 * @author Benjamin Evans, University of Leeds 00019 * @date May 2020 00020 */ 00021 class PlayEngine { 00022 public: 00023 00024 // Function prototypes ----------------------------------------------------- 00025 00026 // Spaceship Control 00027 /** Gets joystick direction from gamepad and stores it in d_ */ 00028 void read_joystick_direction(); 00029 00030 /** Gets the pitch and roll of the gamepad and calculates d_ */ 00031 void read_accelerometer_direction(float roll, float pitch); 00032 00033 /** Turns on specific leds depending on how many lives left */ 00034 void spaceship_lives_leds(); 00035 00036 // Weapon Control 00037 /** Creates weapons object if button A is pressed and stores in vector*/ 00038 void create_weapons_bullets(); 00039 00040 /** Creates smart bomb if button B is pressed */ 00041 void create_weapons_smart_bomb(); 00042 00043 /** Draws each bullet object and deleted object after set movement 00044 * distance 00045 */ 00046 void draw_bullets(); 00047 00048 // Alien Control 00049 /** Spawns aliens in random position of the screen*/ 00050 void spawn_aliens(); 00051 00052 /** Creates alien object and stores in vector*/ 00053 void create_alien(); 00054 00055 /** Checks for alien people collision and sets abduction movements 00056 * @param i @details iterator from draw_alien for loop 00057 */ 00058 void check_alien_people_collision(int i); 00059 00060 /** Gets alien to fire bullets randomly towards spaceship 00061 * @param i @details iterator from draw_alien for loop 00062 */ 00063 void alliens_fire_bullets(int i); 00064 00065 /**Deletes bullet and alien if collision detected and draws explosion 00066 * @param i @details iterator from draw_alien for loop 00067 */ 00068 void delete_aliens(int i); 00069 00070 /** Draws each alien object and deletes both objects if collision 00071 * detected 00072 */ 00073 void draw_aliens(); 00074 00075 // Explosion Control 00076 /** Creates bullet object if button A is pressed and stores in vector */ 00077 void create_explosion(Vector2D destroyed_position); 00078 00079 /** Draws each explosion object if collision detected */ 00080 void draw_explosions(); 00081 00082 // People Control 00083 /** Spawns people in random places at bottom of screen */ 00084 void spawn_people(); 00085 00086 /** Spawns people in random position at bottom of the screen*/ 00087 void create_people(); 00088 00089 /** Draws each people object */ 00090 void draw_people(); 00091 00092 // Map Control 00093 /** Resets map after set time so spaceship explosion animation shows */ 00094 void reset_map_timer(); 00095 00096 /** Resets the map after spaceship death and timer has ended */ 00097 void reset_map(); 00098 00099 // Variables --------------------------------------------------------------- 00100 00101 // Spaceship Control 00102 /** Define points*/ 00103 int points_; 00104 00105 /** Define direction d of joystick*/ 00106 Direction d_; 00107 00108 /** Flag for if spaceship is destroyed*/ 00109 bool spaceship_destroyed_; 00110 00111 /** Number of spaceship lives remaining*/ 00112 int spaceship_lives_; 00113 00114 // Weapon Control 00115 /** Counter for smart bomb timer*/ 00116 int smart_bomb_timer_; 00117 00118 /** Counter for bullet timer*/ 00119 int bullet_timer_; 00120 00121 /** Counter for how smart bombs left*/ 00122 int smart_bomb_counter_; 00123 00124 // Alien Control 00125 /** Counter for spawning aliens*/ 00126 int spawn_alien_counter_; 00127 00128 /** Number of aliens on the screen at a time*/ 00129 int alien_number_; 00130 00131 /** Multiplier to increase number of alien as time goes on */ 00132 int spawn_time_multipler_; 00133 00134 // Map Control 00135 /** Counter to reset map after set amount of frames*/ 00136 int reset_map_counter_; 00137 00138 // FX sound 00139 /** Hold on or off depending if sound fx are set on or off */ 00140 SoundParts sound_fx_; 00141 00142 // Vectors ----------------------------------------------------------------- 00143 00144 /** Vector to store each new bullet object*/ 00145 std::vector<Weapons> bullet_vector; 00146 00147 /** Vector to store each alien bullet object*/ 00148 std::vector<Weapons> alien_bullet_vector; 00149 00150 /** Vector to store each new alien object*/ 00151 std::vector<Alien> alien_vector; 00152 00153 /** Vector to store each new explosion object*/ 00154 std::vector<Explosion> explosion_vector; 00155 00156 /** Vector to store each new people object*/ 00157 std::vector<People> people_vector; 00158 00159 // Objects ----------------------------------------------------------------- 00160 00161 /** Define Gamepad object */ 00162 Gamepad pad; 00163 00164 /** Define LCD object */ 00165 N5110 lcd; 00166 00167 /** Define Spaceship object */ 00168 Spaceship spaceship; 00169 00170 /** Define Map object */ 00171 Map map; 00172 00173 /** Define Weapons object */ 00174 Weapons weapons; 00175 }; 00176 00177 #endif
Generated on Fri Aug 5 2022 06:55:07 by
1.7.2