The game is finished

Dependencies:   mbed Gamepad N5110 mbed-rtos

Committer:
RexRoshan
Date:
Thu May 09 14:23:35 2019 +0000
Revision:
14:c7302ffe6eab
Parent:
13:a2f061b9cc36
Final Modification

Who changed what in which revision?

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