Solar Striker

Dependencies:   mbed Gamepad N5110 mbed-rtos

Committer:
RexRoshan
Date:
Thu May 09 09:49:35 2019 +0000
Revision:
0:d9cf94b41df3
Documentation has been completed and the code has been slightly modified

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RexRoshan 0:d9cf94b41df3 1 #ifndef GAMEENGINE_H
RexRoshan 0:d9cf94b41df3 2 #define GAMEENGINE_H
RexRoshan 0:d9cf94b41df3 3
RexRoshan 0:d9cf94b41df3 4 #include "mbed.h"
RexRoshan 0:d9cf94b41df3 5 #include "N5110.h"
RexRoshan 0:d9cf94b41df3 6 #include "Gamepad.h"
RexRoshan 0:d9cf94b41df3 7 #include "Enemy.h"
RexRoshan 0:d9cf94b41df3 8 #include "Enemy21.h"
RexRoshan 0:d9cf94b41df3 9 #include "Enemy22.h"
RexRoshan 0:d9cf94b41df3 10 #include "EnemyBoss.h"
RexRoshan 0:d9cf94b41df3 11 #include "EnemyBeam.h"
RexRoshan 0:d9cf94b41df3 12 #include "EnemyBeam2.h"
RexRoshan 0:d9cf94b41df3 13 #include "EnemyBeam3.h"
RexRoshan 0:d9cf94b41df3 14 #include "Beam.h"
RexRoshan 0:d9cf94b41df3 15 #include "Spacecraft.h"
RexRoshan 0:d9cf94b41df3 16
RexRoshan 0:d9cf94b41df3 17 // gap from edge of screen
RexRoshan 0:d9cf94b41df3 18 #define GAP 2
RexRoshan 0:d9cf94b41df3 19
RexRoshan 0:d9cf94b41df3 20 /** GameEngine Class
RexRoshan 0:d9cf94b41df3 21 * @brief The game engine for the game
RexRoshan 0:d9cf94b41df3 22 * @author Rex Roshan Raj
RexRoshan 0:d9cf94b41df3 23 */
RexRoshan 0:d9cf94b41df3 24 class GameEngine
RexRoshan 0:d9cf94b41df3 25 {
RexRoshan 0:d9cf94b41df3 26
RexRoshan 0:d9cf94b41df3 27 public:
RexRoshan 0:d9cf94b41df3 28
RexRoshan 0:d9cf94b41df3 29 /** Constructor */
RexRoshan 0:d9cf94b41df3 30 GameEngine();
RexRoshan 0:d9cf94b41df3 31
RexRoshan 0:d9cf94b41df3 32 /** Destructor */
RexRoshan 0:d9cf94b41df3 33 ~GameEngine();
RexRoshan 0:d9cf94b41df3 34
RexRoshan 0:d9cf94b41df3 35 /** Initialise the parameters for the game engine
RexRoshan 0:d9cf94b41df3 36 *@param size - size of the beam
RexRoshan 0:d9cf94b41df3 37 *@param spacecraft_xpos - x position of the player's spacecraft
RexRoshan 0:d9cf94b41df3 38 *@param spacecraft_ypos - y position of the player's spacecraft
RexRoshan 0:d9cf94b41df3 39 *@param enemy_xpos - x position of the enemy in stage one
RexRoshan 0:d9cf94b41df3 40 *@param enemy_ypos - y position of the enemy in stage one
RexRoshan 0:d9cf94b41df3 41 *@param enemy2_xpos - x position of the enemy in stage two
RexRoshan 0:d9cf94b41df3 42 *@param enemy2_ypos - y position of the enemy in stage two
RexRoshan 0:d9cf94b41df3 43 *@param enemy3_xpos - x position of the boss in stage three
RexRoshan 0:d9cf94b41df3 44 *@param enemy3_ypos - y position of the boss in stage three
RexRoshan 0:d9cf94b41df3 45 *@param beam_size - size of the beam in stage one and three
RexRoshan 0:d9cf94b41df3 46 *@param beam2_size - size of the beam in stage two
RexRoshan 0:d9cf94b41df3 47 *@param speed - speed of the objects moving
RexRoshan 0:d9cf94b41df3 48 */
RexRoshan 0:d9cf94b41df3 49 void init(int spacecraft_xpos,int spacecraft_ypos,int enemy_xpos, int enemy_ypos,int enemy2_xpos, int enemy2_ypos,int enemy3_xpos, int enemy3_ypos, int beam_size, int beam2_size, int speed);
RexRoshan 0:d9cf94b41df3 50
RexRoshan 0:d9cf94b41df3 51 /** Read the input
RexRoshan 0:d9cf94b41df3 52 * @param Gamepad pad
RexRoshan 0:d9cf94b41df3 53 * @brief Reads the input from the Gamepad
RexRoshan 0:d9cf94b41df3 54 */
RexRoshan 0:d9cf94b41df3 55 void read_input(Gamepad &pad);
RexRoshan 0:d9cf94b41df3 56
RexRoshan 0:d9cf94b41df3 57 /** Updates mission one
RexRoshan 0:d9cf94b41df3 58 * @param Gamepad pad
RexRoshan 0:d9cf94b41df3 59 * @param N5110 lcd
RexRoshan 0:d9cf94b41df3 60 */
RexRoshan 0:d9cf94b41df3 61 void update_mission_one(Gamepad &pad,N5110 &lcd);
RexRoshan 0:d9cf94b41df3 62
RexRoshan 0:d9cf94b41df3 63
RexRoshan 0:d9cf94b41df3 64 /** Updates mission two
RexRoshan 0:d9cf94b41df3 65 * @param Gamepad pad
RexRoshan 0:d9cf94b41df3 66 * @param N5110 lcd
RexRoshan 0:d9cf94b41df3 67 */
RexRoshan 0:d9cf94b41df3 68 void update_mission_two(Gamepad &pad,N5110 &lcd);
RexRoshan 0:d9cf94b41df3 69
RexRoshan 0:d9cf94b41df3 70
RexRoshan 0:d9cf94b41df3 71 /** Updates mission three
RexRoshan 0:d9cf94b41df3 72 * @param Gamepad pad
RexRoshan 0:d9cf94b41df3 73 * @param N5110 lcd
RexRoshan 0:d9cf94b41df3 74 */
RexRoshan 0:d9cf94b41df3 75 void update_mission_three(Gamepad &pad,N5110 &lcd);
RexRoshan 0:d9cf94b41df3 76
RexRoshan 0:d9cf94b41df3 77 /** Draws objects in mission one
RexRoshan 0:d9cf94b41df3 78 * @param N5110 lcd
RexRoshan 0:d9cf94b41df3 79 * @brief Draws the characters and the beams involved in mission one
RexRoshan 0:d9cf94b41df3 80 */
RexRoshan 0:d9cf94b41df3 81 void draw_mission_one(Gamepad &pad,N5110 &lcd);
RexRoshan 0:d9cf94b41df3 82
RexRoshan 0:d9cf94b41df3 83 /** Draws objects in mission two
RexRoshan 0:d9cf94b41df3 84 * @param N5110 lcd
RexRoshan 0:d9cf94b41df3 85 * @brief Draws the characters and the beams involved in mission two
RexRoshan 0:d9cf94b41df3 86 */
RexRoshan 0:d9cf94b41df3 87 void draw_mission_two(Gamepad &pad,N5110 &lcd);
RexRoshan 0:d9cf94b41df3 88
RexRoshan 0:d9cf94b41df3 89 /** Draws objects in mission three
RexRoshan 0:d9cf94b41df3 90 * @param N5110 lcd
RexRoshan 0:d9cf94b41df3 91 * @brief Draws the characters and the beams involved in mission three
RexRoshan 0:d9cf94b41df3 92 */
RexRoshan 0:d9cf94b41df3 93 void draw_mission_three(Gamepad &pad,N5110 &lcd);
RexRoshan 0:d9cf94b41df3 94
RexRoshan 0:d9cf94b41df3 95 /** Gets the stage of the game
RexRoshan 0:d9cf94b41df3 96 * @returns a value from 1 to 6
RexRoshan 0:d9cf94b41df3 97 */
RexRoshan 0:d9cf94b41df3 98 int get_game_stage();
RexRoshan 0:d9cf94b41df3 99
RexRoshan 0:d9cf94b41df3 100 /** Sets the stage of the game
RexRoshan 0:d9cf94b41df3 101 * @brief Sets the stage of the game to be zero
RexRoshan 0:d9cf94b41df3 102 * @returns a value of 0
RexRoshan 0:d9cf94b41df3 103 */
RexRoshan 0:d9cf94b41df3 104 int restart_game_stage();
RexRoshan 0:d9cf94b41df3 105
RexRoshan 0:d9cf94b41df3 106
RexRoshan 0:d9cf94b41df3 107 private:
RexRoshan 0:d9cf94b41df3 108
RexRoshan 0:d9cf94b41df3 109 void check_enemy_collisions(Gamepad &pad); // check if the player spacecraft beam collided with the enemy in mission one
RexRoshan 0:d9cf94b41df3 110 void check_enemy2_collisions(Gamepad &pad); // check if the player spacecraft beam collided with the enemy in mission two
RexRoshan 0:d9cf94b41df3 111 void check_enemy3_collisions(Gamepad &pad); // check if the player spacecraft beam collided with the enemy in mission three
RexRoshan 0:d9cf94b41df3 112
RexRoshan 0:d9cf94b41df3 113 void check_wall_collision(Gamepad &pad); // check if the enemy in mission one has collided with the wall
RexRoshan 0:d9cf94b41df3 114 void check_wall_collisions(Gamepad &pad); // check if the enemy in mission two has collided with the wall
RexRoshan 0:d9cf94b41df3 115 void check_wall2_collisions(Gamepad &pad); // check if the enemy in mission three has collided with the wall
RexRoshan 0:d9cf94b41df3 116
RexRoshan 0:d9cf94b41df3 117 void enemy_dead(N5110 &lcd,Gamepad &pad); // check if enemy spacecraft is dead
RexRoshan 0:d9cf94b41df3 118 void enemy2_dead(N5110 &lcd,Gamepad &pad); // check if enemy spacecraft is dead
RexRoshan 0:d9cf94b41df3 119 void enemy3_dead(N5110 &lcd,Gamepad &pad); // check if enemy spacecraft is dead
RexRoshan 0:d9cf94b41df3 120
RexRoshan 0:d9cf94b41df3 121 void spacecraft_dead(N5110 &lcd,Gamepad &pad); // check if the player spacecraft is dead
RexRoshan 0:d9cf94b41df3 122 void spacecraft2_dead(N5110 &lcd,Gamepad &pad); // check if the player spacecraft is dead
RexRoshan 0:d9cf94b41df3 123 void spacecraft3_dead(N5110 &lcd,Gamepad &pad); // check if the player spacecraft is dead
RexRoshan 0:d9cf94b41df3 124
RexRoshan 0:d9cf94b41df3 125 void check_spacecraft_collisions(Gamepad &pad); // check if the enemy spacecraft beam collided with the player spacecraft
RexRoshan 0:d9cf94b41df3 126 void check_spacecraft2_collisions(Gamepad &pad); // check if the enemy spacecraft beam collided with the player spacecraft
RexRoshan 0:d9cf94b41df3 127 void check_spacecraft3_collisions(Gamepad &pad); // check if the enemy spacecraft beam collided with the player spacecraft
RexRoshan 0:d9cf94b41df3 128
RexRoshan 0:d9cf94b41df3 129 void check_enemybeam_collisions(Gamepad &pad); // check if the enemy beam in mission one collided with the wall
RexRoshan 0:d9cf94b41df3 130 void check_enemybeam2_collisions(Gamepad &pad); // check if the enemy beam in mission two collided with the wall
RexRoshan 0:d9cf94b41df3 131 void check_enemybeam3_collisions(Gamepad &pad); // check if the enemy beam in mission three collided with the wall
RexRoshan 0:d9cf94b41df3 132
RexRoshan 0:d9cf94b41df3 133 void check_playerbeam_collision(Gamepad &pad); // check if the player's spacecraft beam collided with the wall
RexRoshan 0:d9cf94b41df3 134
RexRoshan 0:d9cf94b41df3 135 void draw_enemy_health(N5110 &lcd); // draw the enemy health in mission one
RexRoshan 0:d9cf94b41df3 136 void draw_enemy21_health(N5110 &lcd); // draw the first enemy health in mission two
RexRoshan 0:d9cf94b41df3 137 void draw_enemy22_health(N5110 &lcd); // draw the second enemy health in mission two
RexRoshan 0:d9cf94b41df3 138 void draw_enemyboss_health(N5110 &lcd); // draw the enemy health in mission three
RexRoshan 0:d9cf94b41df3 139 void draw_spacecraft_health(Gamepad &pad); // draw the player's spacecraft health
RexRoshan 0:d9cf94b41df3 140
RexRoshan 0:d9cf94b41df3 141 Spacecraft _p1; //player spacecraft
RexRoshan 0:d9cf94b41df3 142 Enemy _e1; // first enemy spacecraft
RexRoshan 0:d9cf94b41df3 143 Enemy21 _e21; // second enemy spacecraft
RexRoshan 0:d9cf94b41df3 144 Enemy22 _e22; // second enemy spacecraft
RexRoshan 0:d9cf94b41df3 145 EnemyBoss _e3;
RexRoshan 0:d9cf94b41df3 146
RexRoshan 0:d9cf94b41df3 147 int _spacecraft_xpos; // x position of the spacecrafts
RexRoshan 0:d9cf94b41df3 148 int _spacecraft_ypos; // y position of the spacecrafts
RexRoshan 0:d9cf94b41df3 149
RexRoshan 0:d9cf94b41df3 150 int _enemy_xpos; // x position of the enemy from the WIDTH
RexRoshan 0:d9cf94b41df3 151 int _enemy_ypos; // y position of the enemy from the HEIGHT
RexRoshan 0:d9cf94b41df3 152 int _e1a; // x position of the enemy
RexRoshan 0:d9cf94b41df3 153 int _e1b; // y position of the enemy
RexRoshan 0:d9cf94b41df3 154 int _p1x;
RexRoshan 0:d9cf94b41df3 155
RexRoshan 0:d9cf94b41df3 156 int _enemy2_xpos; // x position of the second enemy from the WIDTH
RexRoshan 0:d9cf94b41df3 157 int _enemy2_ypos; // y position of the second enemy from the HEIGHT
RexRoshan 0:d9cf94b41df3 158 int _e2a; // x position of the second enemy
RexRoshan 0:d9cf94b41df3 159 int _e21b; // y position of the second enemy
RexRoshan 0:d9cf94b41df3 160 int _e22b;
RexRoshan 0:d9cf94b41df3 161
RexRoshan 0:d9cf94b41df3 162 int _enemy3_xpos; // x position of the boss enemy from the WIDTH
RexRoshan 0:d9cf94b41df3 163 int _enemy3_ypos; // y position of the boss enemy from the HEIGHT
RexRoshan 0:d9cf94b41df3 164 int _e3a;
RexRoshan 0:d9cf94b41df3 165 int _e3b;
RexRoshan 0:d9cf94b41df3 166 int _e3c;
RexRoshan 0:d9cf94b41df3 167 int _e3d;
RexRoshan 0:d9cf94b41df3 168 int _e3f;
RexRoshan 0:d9cf94b41df3 169
RexRoshan 0:d9cf94b41df3 170 int _speed; // the beginning speed
RexRoshan 0:d9cf94b41df3 171 int _beam_size; // beam size in mission one and three
RexRoshan 0:d9cf94b41df3 172 int _beam2_size; // beam size in mission two
RexRoshan 0:d9cf94b41df3 173
RexRoshan 0:d9cf94b41df3 174 Beam _beam;
RexRoshan 0:d9cf94b41df3 175 EnemyBeam _enemybeam;
RexRoshan 0:d9cf94b41df3 176 EnemyBeam2 _enemybeam2;
RexRoshan 0:d9cf94b41df3 177 EnemyBeam3 _enemybeam3;
RexRoshan 0:d9cf94b41df3 178
RexRoshan 0:d9cf94b41df3 179 Direction _d;
RexRoshan 0:d9cf94b41df3 180 float _mag;
RexRoshan 0:d9cf94b41df3 181
RexRoshan 0:d9cf94b41df3 182 bool _L;
RexRoshan 0:d9cf94b41df3 183 bool _R;
RexRoshan 0:d9cf94b41df3 184 bool spacebeam;
RexRoshan 0:d9cf94b41df3 185 bool _ebeam;
RexRoshan 0:d9cf94b41df3 186 bool _ebeam21;
RexRoshan 0:d9cf94b41df3 187 bool _ebeam22;
RexRoshan 0:d9cf94b41df3 188 bool _ebeam3boss;
RexRoshan 0:d9cf94b41df3 189 bool _ebeam31;
RexRoshan 0:d9cf94b41df3 190 bool _ebeam32;
RexRoshan 0:d9cf94b41df3 191 int _stage;
RexRoshan 0:d9cf94b41df3 192
RexRoshan 0:d9cf94b41df3 193 };
RexRoshan 0:d9cf94b41df3 194
RexRoshan 0:d9cf94b41df3 195 #endif