Rex Raj / Mbed 2 deprecated el17rrrs

Dependencies:   mbed Gamepad N5110 mbed-rtos

Committer:
RexRoshan
Date:
Wed May 08 10:03:24 2019 +0000
Revision:
6:1fcfd331c047
Parent:
5:016a7315b75d
Documentation has been completed;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RexRoshan 0:99fa5a619081 1 #include "GameEngine.h"
RexRoshan 0:99fa5a619081 2
RexRoshan 0:99fa5a619081 3 GameEngine::GameEngine()
RexRoshan 0:99fa5a619081 4 {
RexRoshan 0:99fa5a619081 5
RexRoshan 0:99fa5a619081 6 }
RexRoshan 0:99fa5a619081 7
RexRoshan 0:99fa5a619081 8 GameEngine::~GameEngine()
RexRoshan 0:99fa5a619081 9 {
RexRoshan 0:99fa5a619081 10
RexRoshan 0:99fa5a619081 11 }
RexRoshan 5:016a7315b75d 12
RexRoshan 5:016a7315b75d 13 // draws the background of the game
RexRoshan 0:99fa5a619081 14 int backgrounds [48][84] = {
RexRoshan 0:99fa5a619081 15
RexRoshan 0:99fa5a619081 16 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
RexRoshan 0:99fa5a619081 17 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
RexRoshan 0:99fa5a619081 18 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,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5a619081 62 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
RexRoshan 0:99fa5a619081 63 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
RexRoshan 0:99fa5a619081 64
RexRoshan 0:99fa5a619081 65 };
RexRoshan 5:016a7315b75d 66
RexRoshan 5:016a7315b75d 67 // draws alphabet r in morse code
RexRoshan 0:99fa5a619081 68 int r [3][13] = {
RexRoshan 0:99fa5a619081 69
RexRoshan 0:99fa5a619081 70 {0,1,0,0,0,0,0,0,0,0,0,1,0},
RexRoshan 0:99fa5a619081 71 {1,1,1,0,0,0,0,0,0,0,1,1,1},
RexRoshan 0:99fa5a619081 72 {0,1,0,0,1,1,1,1,1,0,0,1,0},
RexRoshan 0:99fa5a619081 73
RexRoshan 0:99fa5a619081 74 };
RexRoshan 0:99fa5a619081 75
RexRoshan 5:016a7315b75d 76 // draws alphabet e in morse code
RexRoshan 0:99fa5a619081 77 int e [3][3] = {
RexRoshan 0:99fa5a619081 78
RexRoshan 0:99fa5a619081 79 {0,1,0},
RexRoshan 0:99fa5a619081 80 {1,1,1},
RexRoshan 0:99fa5a619081 81 {0,1,0},
RexRoshan 0:99fa5a619081 82
RexRoshan 0:99fa5a619081 83 };
RexRoshan 0:99fa5a619081 84
RexRoshan 5:016a7315b75d 85 // draws alphabet x in morse code
RexRoshan 0:99fa5a619081 86 int x [3][19] = {
RexRoshan 0:99fa5a619081 87
RexRoshan 0:99fa5a619081 88 {0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0},
RexRoshan 0:99fa5a619081 89 {0,0,0,0,0,0,1,1,1,0,1,1,1,0,0,0,0,0,0},
RexRoshan 0:99fa5a619081 90 {1,1,1,1,1,0,0,1,0,0,0,1,0,0,1,1,1,1,1},
RexRoshan 0:99fa5a619081 91
RexRoshan 0:99fa5a619081 92 };
RexRoshan 0:99fa5a619081 93
RexRoshan 5:016a7315b75d 94 // draws explosion
RexRoshan 0:99fa5a619081 95 int explosion [23] [23] = {
RexRoshan 0:99fa5a619081 96
RexRoshan 0:99fa5a619081 97 {0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0},
RexRoshan 0:99fa5a619081 98 {0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,1,0,0,0,0,0,0},
RexRoshan 0:99fa5a619081 99 {0,0,0,0,0,1,1,1,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0},
RexRoshan 0:99fa5a619081 100 {0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0},
RexRoshan 0:99fa5a619081 101 {0,0,0,1,1,1,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0},
RexRoshan 0:99fa5a619081 102 {0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0},
RexRoshan 0:99fa5a619081 103 {0,1,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,0},
RexRoshan 0:99fa5a619081 104 {0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0},
RexRoshan 0:99fa5a619081 105 {0,1,1,0,0,0,0,1,1,1,0,0,0,0,1,0,0,0,0,0,1,0,0},
RexRoshan 0:99fa5a619081 106 {0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0},
RexRoshan 0:99fa5a619081 107 {0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
RexRoshan 0:99fa5a619081 108 {0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1},
RexRoshan 0:99fa5a619081 109 {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1},
RexRoshan 0:99fa5a619081 110 {0,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0},
RexRoshan 0:99fa5a619081 111 {0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0},
RexRoshan 0:99fa5a619081 112 {0,0,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0},
RexRoshan 0:99fa5a619081 113 {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
RexRoshan 0:99fa5a619081 114 {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0},
RexRoshan 0:99fa5a619081 115 {0,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,1,1,1,0,0},
RexRoshan 0:99fa5a619081 116 {0,0,1,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,1,0,0,0},
RexRoshan 0:99fa5a619081 117 {0,0,0,1,1,1,0,0,1,1,0,1,1,0,0,0,1,1,0,0,0,0,0},
RexRoshan 0:99fa5a619081 118 {0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0},
RexRoshan 0:99fa5a619081 119 {0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0},
RexRoshan 0:99fa5a619081 120
RexRoshan 0:99fa5a619081 121 };
RexRoshan 0:99fa5a619081 122
RexRoshan 1:45493d1d0689 123 void GameEngine::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:99fa5a619081 124 {
RexRoshan 2:b5c1bb7a39de 125 // initialise the game parameters
RexRoshan 2:b5c1bb7a39de 126 _spacecraft_xpos = spacecraft_xpos;
RexRoshan 2:b5c1bb7a39de 127 _spacecraft_ypos = spacecraft_ypos;
RexRoshan 0:99fa5a619081 128
RexRoshan 2:b5c1bb7a39de 129 _enemy_xpos = enemy_xpos;
RexRoshan 2:b5c1bb7a39de 130 _enemy_ypos = enemy_ypos;
RexRoshan 0:99fa5a619081 131
RexRoshan 2:b5c1bb7a39de 132 _enemy2_xpos = enemy2_xpos;
RexRoshan 2:b5c1bb7a39de 133 _enemy2_ypos = enemy2_ypos;
RexRoshan 1:45493d1d0689 134
RexRoshan 2:b5c1bb7a39de 135 _enemy3_xpos = enemy3_xpos;
RexRoshan 2:b5c1bb7a39de 136 _enemy3_ypos = enemy3_ypos;
RexRoshan 0:99fa5a619081 137
RexRoshan 0:99fa5a619081 138
RexRoshan 2:b5c1bb7a39de 139 _beam_size = beam_size; // beam size for 1st and 3rd enemy
RexRoshan 2:b5c1bb7a39de 140 _beam2_size = beam2_size; // beam size for 2nd enemy
RexRoshan 2:b5c1bb7a39de 141 _speed = speed; // Speed of the enemy travelling
RexRoshan 0:99fa5a619081 142
RexRoshan 0:99fa5a619081 143
RexRoshan 2:b5c1bb7a39de 144 _p1x = GAP;
RexRoshan 0:99fa5a619081 145 // x position on screen - WIDTH is defined in N5110.h
RexRoshan 2:b5c1bb7a39de 146 _e1a = WIDTH-_enemy_xpos; //enemy_xpos = 12
RexRoshan 2:b5c1bb7a39de 147 // y position on screen - HEIGHT is defined in N5110.h
RexRoshan 2:b5c1bb7a39de 148 _e1b = HEIGHT/2-_enemy_ypos; //enemy_ypos = 4
RexRoshan 0:99fa5a619081 149
RexRoshan 2:b5c1bb7a39de 150 _e2a = WIDTH-_enemy2_xpos; //enemy2_xpos = 12
RexRoshan 2:b5c1bb7a39de 151 _e21b = HEIGHT/2 +_enemy2_ypos; //enemy2_ypos = 10
RexRoshan 2:b5c1bb7a39de 152 _e22b = HEIGHT/2 -_enemy2_ypos;
RexRoshan 1:45493d1d0689 153
RexRoshan 2:b5c1bb7a39de 154 _e3a = WIDTH-_enemy3_xpos; //enemy3_xpos = 20
RexRoshan 2:b5c1bb7a39de 155 _e3b = HEIGHT/2 -_enemy3_ypos; //enemy3_ypos = 7
RexRoshan 1:45493d1d0689 156 _e3c = WIDTH-_enemy3_xpos - 12;
RexRoshan 1:45493d1d0689 157 _e3d = HEIGHT/2 + _enemy3_ypos;;
RexRoshan 1:45493d1d0689 158 _e3f = HEIGHT/2 - _enemy3_ypos;;
RexRoshan 1:45493d1d0689 159
RexRoshan 2:b5c1bb7a39de 160 // Initialising the player's spacecraft and all enemy spacecrafts
RexRoshan 2:b5c1bb7a39de 161 _p1.init(_spacecraft_xpos,_spacecraft_ypos);
RexRoshan 2:b5c1bb7a39de 162 _e1.init(_e1a,_e1b);
RexRoshan 2:b5c1bb7a39de 163 _e21.init(_e2a,_e21b,_speed);
RexRoshan 2:b5c1bb7a39de 164 _e22.init(_e2a,_e22b,_speed);
RexRoshan 2:b5c1bb7a39de 165 _e3.init(_e3a,_e3b,_e3c,_e3d,_e3c,_e3f,_speed);
RexRoshan 6:1fcfd331c047 166 _e3.motion();
RexRoshan 6:1fcfd331c047 167
RexRoshan 6:1fcfd331c047 168 //_beam.init(_beam_size,p1_pos.x,p1_pos.y);
RexRoshan 2:b5c1bb7a39de 169 // Initialising the stage of the game
RexRoshan 2:b5c1bb7a39de 170 _stage = 0;
RexRoshan 0:99fa5a619081 171
RexRoshan 0:99fa5a619081 172 }
RexRoshan 0:99fa5a619081 173
RexRoshan 0:99fa5a619081 174 void GameEngine::read_input(Gamepad &pad)
RexRoshan 0:99fa5a619081 175 {
RexRoshan 2:b5c1bb7a39de 176 _d = pad.get_direction(); // Get the direction of the joystick
RexRoshan 2:b5c1bb7a39de 177 _mag = pad.get_mag(); // Get the magnitude value
RexRoshan 2:b5c1bb7a39de 178 _R = pad.check_event(Gamepad::R_PRESSED); // Check if the R button is being pressed
RexRoshan 3:bf9624e5b0c3 179 _L = pad.check_event(Gamepad::L_PRESSED); // Check if the L button is being pressed
RexRoshan 0:99fa5a619081 180
RexRoshan 0:99fa5a619081 181 }
RexRoshan 0:99fa5a619081 182
RexRoshan 2:b5c1bb7a39de 183 void GameEngine::draw_mission_one(Gamepad &pad,N5110 &lcd)
RexRoshan 0:99fa5a619081 184 {
RexRoshan 0:99fa5a619081 185 // draw the background of the game
RexRoshan 0:99fa5a619081 186 lcd.drawSprite(0,0,48,84,(int *)backgrounds);
RexRoshan 2:b5c1bb7a39de 187 // draw the easter egg of the game
RexRoshan 0:99fa5a619081 188 lcd.drawSprite(6,4,3,13,(int *)r);
RexRoshan 0:99fa5a619081 189 //health
RexRoshan 0:99fa5a619081 190 draw_enemy_health(lcd);
RexRoshan 0:99fa5a619081 191 draw_spacecraft_health(pad);
RexRoshan 2:b5c1bb7a39de 192 // player spacecraft
RexRoshan 0:99fa5a619081 193 _p1.character(lcd);
RexRoshan 2:b5c1bb7a39de 194 // first enemy
RexRoshan 0:99fa5a619081 195 _e1.enemy(lcd);
RexRoshan 2:b5c1bb7a39de 196 // player spacecraft beam
RexRoshan 0:99fa5a619081 197 _beam.draw(lcd);
RexRoshan 2:b5c1bb7a39de 198 // enemy spacecraft beam
RexRoshan 0:99fa5a619081 199 _enemybeam.draw(lcd);
RexRoshan 0:99fa5a619081 200
RexRoshan 0:99fa5a619081 201 }
RexRoshan 2:b5c1bb7a39de 202 void GameEngine::draw_mission_two(Gamepad &pad,N5110 &lcd)
RexRoshan 0:99fa5a619081 203 {
RexRoshan 2:b5c1bb7a39de 204 // draw the background of the game
RexRoshan 0:99fa5a619081 205 lcd.drawSprite(0,0,48,84,(int *)backgrounds);
RexRoshan 2:b5c1bb7a39de 206 // draw the easter egg of the game
RexRoshan 0:99fa5a619081 207 lcd.drawSprite(6,4,3,3,(int *)e);
RexRoshan 2:b5c1bb7a39de 208 //health
RexRoshan 0:99fa5a619081 209 draw_spacecraft_health(pad);
RexRoshan 0:99fa5a619081 210 draw_enemy21_health(lcd);
RexRoshan 0:99fa5a619081 211 draw_enemy22_health(lcd);
RexRoshan 2:b5c1bb7a39de 212 // player spacecraft
RexRoshan 0:99fa5a619081 213 _p1.character(lcd);
RexRoshan 2:b5c1bb7a39de 214 // second enemy
RexRoshan 0:99fa5a619081 215 _e21.enemy2(lcd);
RexRoshan 0:99fa5a619081 216 _e22.enemy2(lcd);
RexRoshan 2:b5c1bb7a39de 217 // player spacecraft beam
RexRoshan 0:99fa5a619081 218 _beam.draw(lcd);
RexRoshan 2:b5c1bb7a39de 219 // second enemy spacecraft beam
RexRoshan 0:99fa5a619081 220 _enemybeam2.draw(lcd);
RexRoshan 0:99fa5a619081 221
RexRoshan 0:99fa5a619081 222 }
RexRoshan 0:99fa5a619081 223
RexRoshan 2:b5c1bb7a39de 224 void GameEngine::draw_mission_three(Gamepad &pad,N5110 &lcd)
RexRoshan 1:45493d1d0689 225 {
RexRoshan 2:b5c1bb7a39de 226 // draw the background of the game
RexRoshan 1:45493d1d0689 227 lcd.drawSprite(0,0,48,84,(int *)backgrounds);
RexRoshan 2:b5c1bb7a39de 228 // draw the easter egg of the game
RexRoshan 2:b5c1bb7a39de 229 lcd.drawSprite(6,4,3,19,(int *)x);
RexRoshan 2:b5c1bb7a39de 230 //health
RexRoshan 1:45493d1d0689 231 draw_spacecraft_health(pad);
RexRoshan 1:45493d1d0689 232 draw_enemyboss_health(lcd);
RexRoshan 2:b5c1bb7a39de 233 // player spacecraft
RexRoshan 1:45493d1d0689 234 _p1.character(lcd);
RexRoshan 2:b5c1bb7a39de 235 // third and final enemy
RexRoshan 1:45493d1d0689 236 _e3.enemyboss(lcd);
RexRoshan 2:b5c1bb7a39de 237 // player spacecraft beam
RexRoshan 1:45493d1d0689 238 _beam.draw(lcd);
RexRoshan 2:b5c1bb7a39de 239 // third enemy spacecraft beam
RexRoshan 1:45493d1d0689 240 _enemybeam3.draw(lcd);
RexRoshan 1:45493d1d0689 241
RexRoshan 1:45493d1d0689 242 }
RexRoshan 1:45493d1d0689 243
RexRoshan 2:b5c1bb7a39de 244 void GameEngine::update_mission_one(Gamepad &pad,N5110 &lcd)
RexRoshan 0:99fa5a619081 245 {
RexRoshan 2:b5c1bb7a39de 246 check_playerbeam_collision(pad); // Check if L/R is being pressed to initiate the player beam
RexRoshan 2:b5c1bb7a39de 247 check_enemybeam_collisions(pad); // Check if first enemy's beam has passed the wall to initiate a new beam
RexRoshan 2:b5c1bb7a39de 248 // updating spacecraft and enemy before checking collisions so that
RexRoshan 2:b5c1bb7a39de 249 // it displays the right value
RexRoshan 2:b5c1bb7a39de 250 _p1.update(_d,_mag); // Player spacecraft movement update
RexRoshan 2:b5c1bb7a39de 251 _beam.update(); // Player spacecraft's beam update
RexRoshan 2:b5c1bb7a39de 252
RexRoshan 2:b5c1bb7a39de 253 // The enemy spacecraft is stationery in mission one
RexRoshan 2:b5c1bb7a39de 254 _enemybeam.update(); // Enemy spacecraft's beam update
RexRoshan 2:b5c1bb7a39de 255
RexRoshan 2:b5c1bb7a39de 256 check_enemy_collisions(pad); // Check if the player spacecraft beam collides with the enemy spacecraft
RexRoshan 2:b5c1bb7a39de 257 check_spacecraft_collisions(pad); // Check if the enemy spacecraft beam collides with the player spacecraft
RexRoshan 2:b5c1bb7a39de 258
RexRoshan 2:b5c1bb7a39de 259 // Animations and sound effect for the both the player's and enemy' spacecraft when they are dead
RexRoshan 0:99fa5a619081 260 spacecraft_dead(lcd,pad);
RexRoshan 0:99fa5a619081 261 enemy_dead(lcd,pad);
RexRoshan 2:b5c1bb7a39de 262
RexRoshan 0:99fa5a619081 263 }
RexRoshan 0:99fa5a619081 264
RexRoshan 2:b5c1bb7a39de 265 void GameEngine::update_mission_two(Gamepad &pad,N5110 &lcd)
RexRoshan 0:99fa5a619081 266 {
RexRoshan 2:b5c1bb7a39de 267 check_playerbeam_collision(pad); // Check if L/R is being pressed to initiate the player beam
RexRoshan 2:b5c1bb7a39de 268 check_enemybeam2_collisions(pad); // Check if first enemy's beam has passed the wall to initiate a new beam
RexRoshan 2:b5c1bb7a39de 269 // updating spacecraft and enemy before checking collisions so that
RexRoshan 2:b5c1bb7a39de 270 // it displays the right value
RexRoshan 2:b5c1bb7a39de 271 _p1.update(_d,_mag); // Player spacecraft movement update
RexRoshan 2:b5c1bb7a39de 272 _beam.update(); // Player spacecraft's beam update
RexRoshan 2:b5c1bb7a39de 273
RexRoshan 2:b5c1bb7a39de 274 _enemybeam2.update(); // Enemy spacecraft's beam update
RexRoshan 2:b5c1bb7a39de 275 _e21.update(); // Second-one enemy spacecraft movement update
RexRoshan 2:b5c1bb7a39de 276 _e22.update(); // Second-two enemy spacecraft movement update
RexRoshan 2:b5c1bb7a39de 277
RexRoshan 2:b5c1bb7a39de 278 check_enemy2_collisions(pad); // Check if the player spacecraft beam collides with the enemy spacecraft
RexRoshan 2:b5c1bb7a39de 279 check_spacecraft2_collisions(pad); // Check if the enemy spacecraft beam collides with the player spacecraft
RexRoshan 2:b5c1bb7a39de 280 check_wall_collisions(pad); // Check if enemy spacecraft hits the top and bottom wall to bounce off
RexRoshan 2:b5c1bb7a39de 281
RexRoshan 2:b5c1bb7a39de 282 // Animations and sound effect for the both the player's and enemy' spacecraft when they are dead
RexRoshan 0:99fa5a619081 283 spacecraft2_dead(lcd,pad);
RexRoshan 0:99fa5a619081 284 enemy2_dead(lcd,pad);
RexRoshan 0:99fa5a619081 285
RexRoshan 0:99fa5a619081 286 }
RexRoshan 0:99fa5a619081 287
RexRoshan 2:b5c1bb7a39de 288 void GameEngine::update_mission_three(Gamepad &pad,N5110 &lcd)
RexRoshan 1:45493d1d0689 289 {
RexRoshan 2:b5c1bb7a39de 290 check_playerbeam_collision(pad);
RexRoshan 1:45493d1d0689 291 check_enemybeam3_collisions(pad);
RexRoshan 2:b5c1bb7a39de 292
RexRoshan 2:b5c1bb7a39de 293 _p1.update(_d,_mag); // Player spacecraft movement update
RexRoshan 2:b5c1bb7a39de 294 _beam.update(); // Player spacecraft beam update
RexRoshan 2:b5c1bb7a39de 295 _enemybeam3.update(); // Third enemy's spacecraft's beam update
RexRoshan 6:1fcfd331c047 296 //_e3.motion();
RexRoshan 2:b5c1bb7a39de 297 _e3.update(); // Third enemy spacecraft movement update
RexRoshan 2:b5c1bb7a39de 298 check_enemy3_collisions(pad); // Check if the player spacecraft beam collides with the third enemy spacecraft
RexRoshan 2:b5c1bb7a39de 299 check_spacecraft3_collisions(pad); // Check if the third enemy spacecraft beam collides with the player spacecraft
RexRoshan 2:b5c1bb7a39de 300 check_wall2_collisions(pad); // Check if enemy spacecraft hits the top,bottom, wall to bounce off
RexRoshan 2:b5c1bb7a39de 301 // Animations and sound effect for the both the player's and enemy' spacecraft
RexRoshan 1:45493d1d0689 302 spacecraft3_dead(lcd,pad);
RexRoshan 1:45493d1d0689 303 enemy3_dead(lcd,pad);
RexRoshan 1:45493d1d0689 304
RexRoshan 1:45493d1d0689 305 }
RexRoshan 0:99fa5a619081 306 void GameEngine::check_enemy_collisions(Gamepad &pad)
RexRoshan 0:99fa5a619081 307 {
RexRoshan 2:b5c1bb7a39de 308 // read current enemy spacecraft's and player spacecraft's beam attributes
RexRoshan 0:99fa5a619081 309 Vector2D beam_pos = _beam.get_pos();
RexRoshan 0:99fa5a619081 310 Vector2D e1_pos = _e1.get_enemy_pos();
RexRoshan 0:99fa5a619081 311
RexRoshan 2:b5c1bb7a39de 312 // see if player's spacecraft beam has hit the enemy's spacecraft by checking for overlaps
RexRoshan 0:99fa5a619081 313 if (
RexRoshan 0:99fa5a619081 314 (beam_pos.y >= e1_pos.y) && //top
RexRoshan 0:99fa5a619081 315 (beam_pos.y <= e1_pos.y + 7) && //bottom
RexRoshan 0:99fa5a619081 316 (beam_pos.x + _beam_size >= _e1a) && //left
RexRoshan 0:99fa5a619081 317 (beam_pos.x + _beam_size <= _e1a + 8) //right
RexRoshan 0:99fa5a619081 318 ) {
RexRoshan 2:b5c1bb7a39de 319 // add first enemy health
RexRoshan 0:99fa5a619081 320 _e1.add_health();
RexRoshan 1:45493d1d0689 321 spacebeam = true;
RexRoshan 6:1fcfd331c047 322 _e1.location();
RexRoshan 2:b5c1bb7a39de 323 // audio feedback
RexRoshan 0:99fa5a619081 324 pad.tone(1000.0,0.1);
RexRoshan 0:99fa5a619081 325 }
RexRoshan 0:99fa5a619081 326
RexRoshan 0:99fa5a619081 327 // write new attributes
RexRoshan 0:99fa5a619081 328 _beam.set_pos(beam_pos);
RexRoshan 0:99fa5a619081 329 }
RexRoshan 0:99fa5a619081 330
RexRoshan 0:99fa5a619081 331 void GameEngine::check_enemy2_collisions(Gamepad &pad)
RexRoshan 0:99fa5a619081 332 {
RexRoshan 2:b5c1bb7a39de 333 // read curent player spacecraft's beam attributes
RexRoshan 0:99fa5a619081 334 Vector2D beam_pos = _beam.get_pos();
RexRoshan 2:b5c1bb7a39de 335 // check e21 first
RexRoshan 0:99fa5a619081 336 Vector2D e21_pos = _e21.get_enemy21_pos();
RexRoshan 0:99fa5a619081 337
RexRoshan 2:b5c1bb7a39de 338 // see if player's spacecraft beam has hit the enemy's spacecraft by checking for overlaps
RexRoshan 0:99fa5a619081 339 if (
RexRoshan 0:99fa5a619081 340 (beam_pos.y >= e21_pos.y) && //top
RexRoshan 0:99fa5a619081 341 (beam_pos.y <= e21_pos.y + 7) && //bottom
RexRoshan 0:99fa5a619081 342 (beam_pos.x + _beam_size >= _e2a) && //left
RexRoshan 0:99fa5a619081 343 (beam_pos.x + _beam_size <= _e2a + 7) //right
RexRoshan 0:99fa5a619081 344 ) {
RexRoshan 2:b5c1bb7a39de 345 // add health to first second level enemy
RexRoshan 2:b5c1bb7a39de 346 _e21.add_health();
RexRoshan 2:b5c1bb7a39de 347 // set boolean spacebeam true
RexRoshan 2:b5c1bb7a39de 348 spacebeam = true;
RexRoshan 0:99fa5a619081 349 // audio feedback
RexRoshan 0:99fa5a619081 350 pad.tone(1000.0,0.1);
RexRoshan 0:99fa5a619081 351 }
RexRoshan 2:b5c1bb7a39de 352 // check e22 next
RexRoshan 2:b5c1bb7a39de 353 Vector2D e22_pos = _e22.get_enemy22_pos();
RexRoshan 2:b5c1bb7a39de 354
RexRoshan 0:99fa5a619081 355 if (
RexRoshan 0:99fa5a619081 356 (beam_pos.y >= e22_pos.y) && //top
RexRoshan 0:99fa5a619081 357 (beam_pos.y <= e22_pos.y + 7) && //bottom
RexRoshan 0:99fa5a619081 358 (beam_pos.x + _beam_size >= _e2a) && //left
RexRoshan 0:99fa5a619081 359 (beam_pos.x + _beam_size <= _e2a + 7) //right
RexRoshan 0:99fa5a619081 360 ) {
RexRoshan 2:b5c1bb7a39de 361 // add health to second, second level enemy
RexRoshan 2:b5c1bb7a39de 362 _e22.add_health();
RexRoshan 2:b5c1bb7a39de 363 // set boolean spacebeam true
RexRoshan 2:b5c1bb7a39de 364 spacebeam = true;
RexRoshan 0:99fa5a619081 365 // audio feedback
RexRoshan 1:45493d1d0689 366 pad.tone(1000.0,0.1);
RexRoshan 1:45493d1d0689 367 }
RexRoshan 2:b5c1bb7a39de 368
RexRoshan 1:45493d1d0689 369 // write new attributes
RexRoshan 1:45493d1d0689 370 _beam.set_pos(beam_pos);
RexRoshan 1:45493d1d0689 371 }
RexRoshan 1:45493d1d0689 372
RexRoshan 1:45493d1d0689 373 void GameEngine::check_enemy3_collisions(Gamepad &pad)
RexRoshan 1:45493d1d0689 374 {
RexRoshan 2:b5c1bb7a39de 375 // read curent player's spacecraft beam attributes
RexRoshan 1:45493d1d0689 376 Vector2D beam_pos = _beam.get_pos();
RexRoshan 1:45493d1d0689 377
RexRoshan 2:b5c1bb7a39de 378 // check e3boss first
RexRoshan 1:45493d1d0689 379 Vector2D e3boss_pos = _e3.get_enemyboss_pos();
RexRoshan 1:45493d1d0689 380
RexRoshan 2:b5c1bb7a39de 381 // see if player's spacecraft beam has hit the enemy's spacecraft by checking for overlaps
RexRoshan 1:45493d1d0689 382 if (
RexRoshan 1:45493d1d0689 383 (beam_pos.y >= e3boss_pos.y) && //top
RexRoshan 1:45493d1d0689 384 (beam_pos.y <= e3boss_pos.y + 12) && //bottom
RexRoshan 1:45493d1d0689 385 (beam_pos.x + _beam_size >= _e3a) && //left
RexRoshan 1:45493d1d0689 386 (beam_pos.x + _beam_size <= _e3a + 12) //right
RexRoshan 1:45493d1d0689 387 ) {
RexRoshan 2:b5c1bb7a39de 388 // add health to enemy boss
RexRoshan 2:b5c1bb7a39de 389 _e3.add_health_boss();
RexRoshan 2:b5c1bb7a39de 390 // set boolean spacebeam true
RexRoshan 2:b5c1bb7a39de 391 spacebeam = true;
RexRoshan 1:45493d1d0689 392 // audio feedback
RexRoshan 1:45493d1d0689 393 pad.tone(1000.0,0.1);
RexRoshan 1:45493d1d0689 394 }
RexRoshan 2:b5c1bb7a39de 395 // check e3enemy1 next
RexRoshan 2:b5c1bb7a39de 396 Vector2D e3enemy1_pos = _e3.get_enemy1_pos();
RexRoshan 2:b5c1bb7a39de 397
RexRoshan 1:45493d1d0689 398 if (
RexRoshan 1:45493d1d0689 399 (beam_pos.y >= e3enemy1_pos.y) && //top
RexRoshan 1:45493d1d0689 400 (beam_pos.y <= e3enemy1_pos.y + 6) && //bottom
RexRoshan 1:45493d1d0689 401 (beam_pos.x + _beam_size >= _e3c) && //left
RexRoshan 1:45493d1d0689 402 (beam_pos.x + _beam_size <= _e3c + 7) //right
RexRoshan 1:45493d1d0689 403 ) {
RexRoshan 2:b5c1bb7a39de 404 // add health to first third level enemy
RexRoshan 2:b5c1bb7a39de 405 _e3.add_health_enemy1();
RexRoshan 2:b5c1bb7a39de 406 // set boolean spacebeam true
RexRoshan 2:b5c1bb7a39de 407 spacebeam = true;
RexRoshan 1:45493d1d0689 408 // audio feedback
RexRoshan 1:45493d1d0689 409 pad.tone(1000.0,0.1);
RexRoshan 1:45493d1d0689 410 }
RexRoshan 2:b5c1bb7a39de 411 // check e3enemy2 next
RexRoshan 2:b5c1bb7a39de 412 Vector2D e3enemy2_pos = _e3.get_enemy2_pos();
RexRoshan 2:b5c1bb7a39de 413
RexRoshan 1:45493d1d0689 414 if (
RexRoshan 1:45493d1d0689 415 (beam_pos.y >= e3enemy2_pos.y) && //top
RexRoshan 1:45493d1d0689 416 (beam_pos.y <= e3enemy2_pos.y + 6) && //bottom
RexRoshan 1:45493d1d0689 417 (beam_pos.x + _beam_size >= _e3c) && //left
RexRoshan 1:45493d1d0689 418 (beam_pos.x + _beam_size <= _e3c + 7) //right
RexRoshan 1:45493d1d0689 419 ) {
RexRoshan 2:b5c1bb7a39de 420 // add health to second third level enemy
RexRoshan 1:45493d1d0689 421 _e3.add_health_enemy2();
RexRoshan 2:b5c1bb7a39de 422 // set boolean spacebeam true
RexRoshan 1:45493d1d0689 423 spacebeam = true;
RexRoshan 2:b5c1bb7a39de 424 // audio feedback
RexRoshan 0:99fa5a619081 425 pad.tone(1000.0,0.1);
RexRoshan 0:99fa5a619081 426 }
RexRoshan 0:99fa5a619081 427 // write new attributes
RexRoshan 0:99fa5a619081 428 _beam.set_pos(beam_pos);
RexRoshan 0:99fa5a619081 429 }
RexRoshan 0:99fa5a619081 430
RexRoshan 5:016a7315b75d 431 void GameEngine::check_playerbeam_collision(Gamepad &pad) // check if player's spacecraft beam has collided with the edges of screen or enemy
RexRoshan 0:99fa5a619081 432 {
RexRoshan 2:b5c1bb7a39de 433 Vector2D p1_pos = _p1.get_pos(); // Get player's spacecraft position
RexRoshan 2:b5c1bb7a39de 434 Vector2D beam_pos = _beam.get_pos(); // Get player's spacecraft beam position
RexRoshan 2:b5c1bb7a39de 435
RexRoshan 5:016a7315b75d 436 if((_R == true)|| (_L == true)){
RexRoshan 5:016a7315b75d 437 if ((beam_pos.x + _beam_size > WIDTH) || (spacebeam == true)){ // if hits the enemy or the wall
RexRoshan 6:1fcfd331c047 438 _beam.init(_beam_size,p1_pos.x,p1_pos.y);
RexRoshan 5:016a7315b75d 439 _R = false; // Then set the boolean _R and _L to false
RexRoshan 2:b5c1bb7a39de 440 _L = false;
RexRoshan 4:4d673fb2d9dc 441 }
RexRoshan 0:99fa5a619081 442 }
RexRoshan 0:99fa5a619081 443 }
RexRoshan 0:99fa5a619081 444
RexRoshan 5:016a7315b75d 445 void GameEngine::check_enemybeam_collisions(Gamepad &pad) // check if enemy beam has collided with the edges of screen or spacecraft in stage one
RexRoshan 0:99fa5a619081 446 {
RexRoshan 6:1fcfd331c047 447 Vector2D enemy_pos = _e1.get_enemy_pos(); // Position of the first enemy
RexRoshan 4:4d673fb2d9dc 448 Vector2D enemybeam_pos = _enemybeam.get_pos(); // Get first enemy's beam position
RexRoshan 4:4d673fb2d9dc 449
RexRoshan 5:016a7315b75d 450 if ((_ebeam == true)||(enemybeam_pos.x - _beam_size < 0)) { // if hits the speacecraft or the wall
RexRoshan 6:1fcfd331c047 451 _enemybeam.init(_beam_size,enemy_pos.x,enemy_pos.y); // Initialise the enemy beam in stage one
RexRoshan 5:016a7315b75d 452 _ebeam = false; // Then set the boolean _ebeam to false
RexRoshan 0:99fa5a619081 453 }
RexRoshan 0:99fa5a619081 454 }
RexRoshan 0:99fa5a619081 455
RexRoshan 5:016a7315b75d 456 void GameEngine::check_enemybeam2_collisions(Gamepad &pad) // check if enemy beam has collided with the edges of screen or spacecraft in stage two
RexRoshan 0:99fa5a619081 457 {
RexRoshan 5:016a7315b75d 458 Vector2D enemy21_pos = _e21.get_enemy21_pos(); // Get first enemy's position in stage two
RexRoshan 5:016a7315b75d 459 Vector2D enemy22_pos = _e22.get_enemy22_pos(); // Get second enemy's position in stage two
RexRoshan 5:016a7315b75d 460 Vector2D enemybeam21_pos = _enemybeam2.get_pos_21(); // Get first enemy's beam position in stage two
RexRoshan 5:016a7315b75d 461 Vector2D enemybeam22_pos = _enemybeam2.get_pos_22(); // Get second enemy's beam position in stage two
RexRoshan 5:016a7315b75d 462
RexRoshan 5:016a7315b75d 463 if ((_ebeam21 == true)||(_ebeam22 == true)||(enemybeam21_pos.x - _beam2_size < 0)||(enemybeam22_pos.x - _beam2_size < 0)) { // if hits the speacecraft or the wall
RexRoshan 5:016a7315b75d 464 _enemybeam2.init(_beam2_size,enemy21_pos.x,enemy21_pos.y,enemy22_pos.x,enemy22_pos.y); // Initialise the enemy beam in stage two
RexRoshan 5:016a7315b75d 465 _ebeam21 = false; // Then set the boolean _ebeam21 and _ebeam22 to false
RexRoshan 0:99fa5a619081 466 _ebeam22 = false;
RexRoshan 0:99fa5a619081 467 }
RexRoshan 0:99fa5a619081 468 }
RexRoshan 0:99fa5a619081 469
RexRoshan 5:016a7315b75d 470 void GameEngine::check_enemybeam3_collisions(Gamepad &pad) // check if enemy beam has collided with the edges of screen or spacecraft in stage three
RexRoshan 1:45493d1d0689 471 {
RexRoshan 5:016a7315b75d 472 Vector2D enemyboss_pos = _e3.get_enemyboss_pos(); // Get boss enemy's position in stage three
RexRoshan 5:016a7315b75d 473 Vector2D enemy1_pos = _e3.get_enemy1_pos(); // Get first regular enemy's position in stage three
RexRoshan 5:016a7315b75d 474 Vector2D enemy2_pos = _e3.get_enemy2_pos(); // Get second regular enemy's position in stage three
RexRoshan 1:45493d1d0689 475
RexRoshan 5:016a7315b75d 476 Vector2D enemybossbeam3_pos = _enemybeam3.get_pos_boss(); // Get boss enemy's beam position in stage three
RexRoshan 5:016a7315b75d 477 Vector2D enemy1beam3_pos = _enemybeam3.get_pos_enemy1(); // Get first regular enemy's beam position in stage three
RexRoshan 5:016a7315b75d 478 Vector2D enemy2beam3_pos = _enemybeam3.get_pos_enemy2(); // Get second regular enemy's beam position in stage three
RexRoshan 5:016a7315b75d 479
RexRoshan 5:016a7315b75d 480 if ((_ebeam3boss == true)||(_ebeam31 == true)||(_ebeam32 == true)||(enemybossbeam3_pos.x - _beam_size < 0)||(enemy1beam3_pos.x - _beam_size < 0)||(enemy2beam3_pos.x - _beam_size < 0)) { // if hits the speacecraft or the wall
RexRoshan 5:016a7315b75d 481 _enemybeam3.init(_beam_size,enemyboss_pos.x,enemyboss_pos.y,enemy1_pos.x,enemy1_pos.y,enemy2_pos.x,enemy2_pos.y); // Initialise the enemy beam in stage three
RexRoshan 5:016a7315b75d 482 _ebeam3boss = false; // Then set boolean _ebeam3boss,_ebeam31, _ebeam32 to false
RexRoshan 1:45493d1d0689 483 _ebeam31 = false;
RexRoshan 1:45493d1d0689 484 _ebeam32 = false;
RexRoshan 1:45493d1d0689 485 }
RexRoshan 1:45493d1d0689 486 }
RexRoshan 1:45493d1d0689 487
RexRoshan 5:016a7315b75d 488 void GameEngine::check_spacecraft_collisions(Gamepad &pad) // check spacecraft collision with enemy beam in stage one
RexRoshan 0:99fa5a619081 489 {
RexRoshan 5:016a7315b75d 490 Vector2D enemybeam_pos = _enemybeam.get_pos(); // Gets the position of the enemy's beam in stage one
RexRoshan 5:016a7315b75d 491 Vector2D p1_pos = _p1.get_pos(); // Gets the position of the player's spacecraft
RexRoshan 0:99fa5a619081 492
RexRoshan 0:99fa5a619081 493 // see if beam has hit the enemy by checking for overlaps
RexRoshan 0:99fa5a619081 494 if (
RexRoshan 0:99fa5a619081 495 (enemybeam_pos.y >= p1_pos.y) && //top
RexRoshan 0:99fa5a619081 496 (enemybeam_pos.y <= p1_pos.y + 11) && //bottom
RexRoshan 0:99fa5a619081 497 (enemybeam_pos.x >= _p1x) && //left
RexRoshan 0:99fa5a619081 498 (enemybeam_pos.x <= _p1x + 11) //right
RexRoshan 0:99fa5a619081 499 ) {
RexRoshan 5:016a7315b75d 500 _p1.add_health(); // adds health
RexRoshan 5:016a7315b75d 501 _ebeam = true; // sets boolean to true to initialise beam
RexRoshan 6:1fcfd331c047 502 pad.tone(87.3,0.1); // outputs sound if it hits the player's spacecraft
RexRoshan 0:99fa5a619081 503 }
RexRoshan 5:016a7315b75d 504 // write new attributes
RexRoshan 0:99fa5a619081 505 _enemybeam.set_pos(enemybeam_pos);
RexRoshan 0:99fa5a619081 506
RexRoshan 0:99fa5a619081 507 }
RexRoshan 0:99fa5a619081 508
RexRoshan 5:016a7315b75d 509 void GameEngine::check_spacecraft2_collisions(Gamepad &pad) // check spacecraft collision with enemy beam in stage two
RexRoshan 0:99fa5a619081 510 {
RexRoshan 5:016a7315b75d 511 Vector2D enemybeam21_pos = _enemybeam2.get_pos_21(); // Gets the position of the first enemy's beam in stage two
RexRoshan 5:016a7315b75d 512 Vector2D enemybeam22_pos = _enemybeam2.get_pos_22(); // Gets the position of the second enemy's beam in stage two
RexRoshan 5:016a7315b75d 513 Vector2D p1_pos = _p1.get_pos(); // Gets the position of the player's spacecraft
RexRoshan 0:99fa5a619081 514
RexRoshan 0:99fa5a619081 515 // see if beam has hit the enemy by checking for overlaps
RexRoshan 0:99fa5a619081 516 if (
RexRoshan 0:99fa5a619081 517 (enemybeam21_pos.y >= p1_pos.y) && //top
RexRoshan 0:99fa5a619081 518 (enemybeam21_pos.y <= p1_pos.y + 11) && //bottom
RexRoshan 0:99fa5a619081 519 (enemybeam21_pos.x >= _p1x) && //left
RexRoshan 0:99fa5a619081 520 (enemybeam21_pos.x <= _p1x + 11) //right
RexRoshan 0:99fa5a619081 521 ) {
RexRoshan 5:016a7315b75d 522 _p1.add_health(); // adds health
RexRoshan 5:016a7315b75d 523 _ebeam21 = true; // sets boolean to true to initialise beam
RexRoshan 6:1fcfd331c047 524 pad.tone(87.3,0.1); // outputs sound if it hits the player's spacecraft
RexRoshan 0:99fa5a619081 525 }
RexRoshan 1:45493d1d0689 526 else if (
RexRoshan 0:99fa5a619081 527 (enemybeam22_pos.y >= p1_pos.y) && //top
RexRoshan 0:99fa5a619081 528 (enemybeam22_pos.y <= p1_pos.y + 11) && //bottom
RexRoshan 0:99fa5a619081 529 (enemybeam22_pos.x >= _p1x) && //left
RexRoshan 0:99fa5a619081 530 (enemybeam22_pos.x <= _p1x + 11) //right
RexRoshan 0:99fa5a619081 531 ) {
RexRoshan 5:016a7315b75d 532 _p1.add_health(); // adds health
RexRoshan 5:016a7315b75d 533 _ebeam22 = true; // sets boolean to true to initialise beam
RexRoshan 6:1fcfd331c047 534 pad.tone(87.3,0.1); // outputs sound if it hits the player's spacecraft
RexRoshan 0:99fa5a619081 535 }
RexRoshan 5:016a7315b75d 536 // write new attributes
RexRoshan 0:99fa5a619081 537 _enemybeam2.set_pos_21(enemybeam21_pos);
RexRoshan 0:99fa5a619081 538 _enemybeam2.set_pos_22(enemybeam22_pos);
RexRoshan 0:99fa5a619081 539
RexRoshan 0:99fa5a619081 540 }
RexRoshan 1:45493d1d0689 541
RexRoshan 5:016a7315b75d 542 void GameEngine::check_spacecraft3_collisions(Gamepad &pad) // check spacecraft collision with enemy beam in stage three
RexRoshan 1:45493d1d0689 543 {
RexRoshan 5:016a7315b75d 544 Vector2D enemybossbeam_pos = _enemybeam3.get_pos_boss(); // Gets the position of the boss enemy's beam in stage three
RexRoshan 5:016a7315b75d 545 Vector2D enemy1beam_pos = _enemybeam3.get_pos_enemy1(); // Gets the position of the first enemy's beam in stage three
RexRoshan 5:016a7315b75d 546 Vector2D enemy2beam_pos = _enemybeam3.get_pos_enemy2(); // Gets the position of the second enemy's beam in stage three
RexRoshan 1:45493d1d0689 547
RexRoshan 5:016a7315b75d 548 Vector2D p1_pos = _p1.get_pos(); // Gets the position of the player's spacecraft
RexRoshan 1:45493d1d0689 549
RexRoshan 1:45493d1d0689 550 // see if beam has hit the enemy by checking for overlaps
RexRoshan 1:45493d1d0689 551 if (
RexRoshan 1:45493d1d0689 552 (enemybossbeam_pos.y >= p1_pos.y) && //top
RexRoshan 1:45493d1d0689 553 (enemybossbeam_pos.y <= p1_pos.y + 11) && //bottom
RexRoshan 1:45493d1d0689 554 (enemybossbeam_pos.x >= _p1x) && //left
RexRoshan 1:45493d1d0689 555 (enemybossbeam_pos.x <= _p1x + 11) //right
RexRoshan 1:45493d1d0689 556 ) {
RexRoshan 5:016a7315b75d 557 _p1.add_health(); // adds health
RexRoshan 5:016a7315b75d 558 _ebeam3boss = true; // sets boolean to true to initialise beam
RexRoshan 6:1fcfd331c047 559 pad.tone(87.3,0.1);
RexRoshan 1:45493d1d0689 560 }
RexRoshan 1:45493d1d0689 561 else if (
RexRoshan 1:45493d1d0689 562 (enemy1beam_pos.y >= p1_pos.y) && //top
RexRoshan 1:45493d1d0689 563 (enemy1beam_pos.y <= p1_pos.y + 11) && //bottom
RexRoshan 1:45493d1d0689 564 (enemy1beam_pos.x >= _p1x) && //left
RexRoshan 1:45493d1d0689 565 (enemy1beam_pos.x <= _p1x + 11) //right
RexRoshan 1:45493d1d0689 566 ) {
RexRoshan 5:016a7315b75d 567 _p1.add_health(); // adds health
RexRoshan 5:016a7315b75d 568 _ebeam31 = true; // sets boolean to true to initialise beam
RexRoshan 6:1fcfd331c047 569 pad.tone(87.3,0.1);
RexRoshan 1:45493d1d0689 570 }
RexRoshan 1:45493d1d0689 571 else if (
RexRoshan 1:45493d1d0689 572 (enemy2beam_pos.y >= p1_pos.y) && //top
RexRoshan 1:45493d1d0689 573 (enemy2beam_pos.y <= p1_pos.y + 11) && //bottom
RexRoshan 1:45493d1d0689 574 (enemy2beam_pos.x >= _p1x) && //left
RexRoshan 1:45493d1d0689 575 (enemy2beam_pos.x <= _p1x + 11) //right
RexRoshan 1:45493d1d0689 576 ) {
RexRoshan 5:016a7315b75d 577 _p1.add_health(); // adds health
RexRoshan 5:016a7315b75d 578 _ebeam32 = true; // sets boolean to true to initialise beam
RexRoshan 6:1fcfd331c047 579 pad.tone(87.3,0.1); // outputs sound if it hits the player's spacecraft
RexRoshan 1:45493d1d0689 580 }
RexRoshan 5:016a7315b75d 581 // write new attributes
RexRoshan 1:45493d1d0689 582 _enemybeam3.set_pos_boss(enemybossbeam_pos);
RexRoshan 1:45493d1d0689 583 _enemybeam3.set_pos_enemy1(enemy1beam_pos);
RexRoshan 1:45493d1d0689 584 _enemybeam3.set_pos_enemy2(enemy2beam_pos);
RexRoshan 1:45493d1d0689 585
RexRoshan 1:45493d1d0689 586 }
RexRoshan 6:1fcfd331c047 587 void GameEngine::check_wall_collision(Gamepad &pad) // check wall collision for enemy in stage one
RexRoshan 6:1fcfd331c047 588 {
RexRoshan 6:1fcfd331c047 589 // read current enemy attributes for boss in stage three
RexRoshan 6:1fcfd331c047 590 Vector2D enemy_pos = _e1.get_enemy_pos();
RexRoshan 1:45493d1d0689 591
RexRoshan 6:1fcfd331c047 592 // check if hit top wall
RexRoshan 6:1fcfd331c047 593 if (enemy_pos.y <= 1) { // 1 due to 1 pixel boundary
RexRoshan 6:1fcfd331c047 594 enemy_pos.y = 1; // bounce off ceiling without going off screen
RexRoshan 6:1fcfd331c047 595 }
RexRoshan 6:1fcfd331c047 596 // check if hit bottom wall
RexRoshan 6:1fcfd331c047 597 else if (enemy_pos.y + 12 >= (HEIGHT-1) ) { // bottom pixel is 47
RexRoshan 6:1fcfd331c047 598 enemy_pos.y = (HEIGHT-1) - 12; // stops ball going off screen
RexRoshan 6:1fcfd331c047 599 // check if hit right wall
RexRoshan 6:1fcfd331c047 600 }else if (enemy_pos.x + 12 >= (WIDTH-1) ) { // right pixel is 83
RexRoshan 6:1fcfd331c047 601 enemy_pos.x = (WIDTH-1) - 12; // stops ball going off screen
RexRoshan 6:1fcfd331c047 602 // check if left right wall
RexRoshan 6:1fcfd331c047 603 }else if (enemy_pos.x <= WIDTH/2) { // half the width (42)
RexRoshan 6:1fcfd331c047 604 enemy_pos.x = WIDTH/2; // bounce off ceiling without going halfway
RexRoshan 6:1fcfd331c047 605 }
RexRoshan 6:1fcfd331c047 606 _e1.set_enemy_pos(enemy_pos);
RexRoshan 6:1fcfd331c047 607
RexRoshan 6:1fcfd331c047 608 }
RexRoshan 6:1fcfd331c047 609
RexRoshan 5:016a7315b75d 610 void GameEngine::check_wall_collisions(Gamepad &pad) // check wall collision for enemies in stage two
RexRoshan 0:99fa5a619081 611 {
RexRoshan 5:016a7315b75d 612 // read current attributes of the enemies
RexRoshan 0:99fa5a619081 613 Vector2D enemy21_pos = _e21.get_enemy21_pos();
RexRoshan 0:99fa5a619081 614 Vector2D enemy22_pos = _e22.get_enemy22_pos();
RexRoshan 0:99fa5a619081 615 Vector2D enemy21_movement = _e21.get_movement();
RexRoshan 0:99fa5a619081 616 Vector2D enemy22_movement = _e22.get_movement();
RexRoshan 0:99fa5a619081 617
RexRoshan 0:99fa5a619081 618 // check if hit top wall
RexRoshan 5:016a7315b75d 619 // first enemy
RexRoshan 0:99fa5a619081 620 if (enemy21_pos.y <= 1) { // 1 due to 1 pixel boundary
RexRoshan 0:99fa5a619081 621 enemy21_pos.y = 1; // bounce off ceiling without going off screen
RexRoshan 0:99fa5a619081 622 enemy21_movement.y = -enemy21_movement.y;
RexRoshan 0:99fa5a619081 623 }
RexRoshan 5:016a7315b75d 624 //second enemy
RexRoshan 5:016a7315b75d 625 else if (enemy22_pos.y <= 1) {
RexRoshan 5:016a7315b75d 626 enemy22_pos.y = 1;
RexRoshan 5:016a7315b75d 627 enemy22_movement.y = -enemy22_movement.y;
RexRoshan 5:016a7315b75d 628 }
RexRoshan 0:99fa5a619081 629 // check if hit bottom wall
RexRoshan 5:016a7315b75d 630 // first enemy
RexRoshan 0:99fa5a619081 631 else if (enemy21_pos.y + 7 >= (HEIGHT-1) ) { // bottom pixel is 47
RexRoshan 0:99fa5a619081 632 enemy21_pos.y = (HEIGHT-1) - 7; // stops ball going off screen
RexRoshan 0:99fa5a619081 633 enemy21_movement.y = -enemy21_movement.y;
RexRoshan 5:016a7315b75d 634 // second enemy
RexRoshan 5:016a7315b75d 635 } else if (enemy22_pos.y + 7 >= (HEIGHT-1) ) {
RexRoshan 5:016a7315b75d 636 enemy22_pos.y = (HEIGHT-1) - 7;
RexRoshan 0:99fa5a619081 637 enemy22_movement.y = -enemy22_movement.y;
RexRoshan 5:016a7315b75d 638
RexRoshan 5:016a7315b75d 639 }
RexRoshan 0:99fa5a619081 640
RexRoshan 5:016a7315b75d 641 // update first and second enemy parameters
RexRoshan 0:99fa5a619081 642 _e21.set_movement(enemy21_movement);
RexRoshan 0:99fa5a619081 643 _e22.set_movement(enemy22_movement);
RexRoshan 0:99fa5a619081 644 _e21.set_enemy21_pos(enemy21_pos);
RexRoshan 0:99fa5a619081 645 _e22.set_enemy22_pos(enemy22_pos);
RexRoshan 0:99fa5a619081 646 }
RexRoshan 1:45493d1d0689 647
RexRoshan 5:016a7315b75d 648 void GameEngine::check_wall2_collisions(Gamepad &pad) // check wall collision for enemies in stage three
RexRoshan 1:45493d1d0689 649 {
RexRoshan 5:016a7315b75d 650 // read current enemy attributes for boss in stage three
RexRoshan 1:45493d1d0689 651 Vector2D enemyboss_pos = _e3.get_enemyboss_pos();
RexRoshan 1:45493d1d0689 652 Vector2D enemyboss_movement = _e3.get_movement();
RexRoshan 1:45493d1d0689 653
RexRoshan 1:45493d1d0689 654 // check if hit top wall
RexRoshan 1:45493d1d0689 655 if (enemyboss_pos.y <= 1) { // 1 due to 1 pixel boundary
RexRoshan 1:45493d1d0689 656 enemyboss_pos.y = 1; // bounce off ceiling without going off screen
RexRoshan 6:1fcfd331c047 657 enemyboss_movement = _e3.motion();
RexRoshan 1:45493d1d0689 658 }
RexRoshan 1:45493d1d0689 659 // check if hit bottom wall
RexRoshan 1:45493d1d0689 660 else if (enemyboss_pos.y + 12 >= (HEIGHT-1) ) { // bottom pixel is 47
RexRoshan 1:45493d1d0689 661 enemyboss_pos.y = (HEIGHT-1) - 12; // stops ball going off screen
RexRoshan 6:1fcfd331c047 662 enemyboss_movement = _e3.motion();
RexRoshan 5:016a7315b75d 663 // check if hit right wall
RexRoshan 5:016a7315b75d 664 }else if (enemyboss_pos.x + 12 >= (WIDTH-1) ) { // right pixel is 83
RexRoshan 1:45493d1d0689 665 enemyboss_pos.x = (WIDTH-1) - 12; // stops ball going off screen
RexRoshan 6:1fcfd331c047 666 enemyboss_movement = _e3.motion();
RexRoshan 5:016a7315b75d 667 // check if left right wall
RexRoshan 5:016a7315b75d 668 }else if (enemyboss_pos.x <= WIDTH/2) { // half the width (42)
RexRoshan 1:45493d1d0689 669 enemyboss_pos.x = WIDTH/2; // bounce off ceiling without going halfway
RexRoshan 6:1fcfd331c047 670 enemyboss_movement = _e3.motion();
RexRoshan 1:45493d1d0689 671 }
RexRoshan 5:016a7315b75d 672 // update boss enemy parameters
RexRoshan 1:45493d1d0689 673 _e3.set_movement(enemyboss_movement);
RexRoshan 1:45493d1d0689 674 _e3.set_enemyboss_pos(enemyboss_pos);
RexRoshan 1:45493d1d0689 675
RexRoshan 1:45493d1d0689 676 }
RexRoshan 1:45493d1d0689 677
RexRoshan 5:016a7315b75d 678 void GameEngine::enemy_dead(N5110 &lcd, Gamepad &pad){ // animation when the enemy is dead in stage one
RexRoshan 5:016a7315b75d 679
RexRoshan 5:016a7315b75d 680 int e1_health = _e1.get_health(); // Gets the health of the enemy
RexRoshan 5:016a7315b75d 681 Vector2D e1_pos = _e1.get_enemy_pos(); // Gets the position of the enemy
RexRoshan 5:016a7315b75d 682
RexRoshan 5:016a7315b75d 683 if (e1_health == 10){
RexRoshan 5:016a7315b75d 684 // explodes and outputs sound if the enemy is dead
RexRoshan 0:99fa5a619081 685 lcd.drawSprite(e1_pos.x-10,e1_pos.y-10,23,23,(int *)explosion);
RexRoshan 0:99fa5a619081 686 pad.tone(1000.0,0.5);
RexRoshan 0:99fa5a619081 687 pad.tone(800.0,0.5);
RexRoshan 0:99fa5a619081 688 pad.tone(600.0,0.5);
RexRoshan 0:99fa5a619081 689 pad.tone(400.0,0.5);
RexRoshan 0:99fa5a619081 690 wait(0.5);
RexRoshan 0:99fa5a619081 691 _e1.update();
RexRoshan 5:016a7315b75d 692 lcd.drawSprite(e1_pos.x-10,e1_pos.y-10,23,23,(int *)explosion);
RexRoshan 5:016a7315b75d 693 _stage = 2; // mission one pass
RexRoshan 0:99fa5a619081 694 lcd.refresh();
RexRoshan 0:99fa5a619081 695 }
RexRoshan 0:99fa5a619081 696
RexRoshan 0:99fa5a619081 697 }
RexRoshan 0:99fa5a619081 698
RexRoshan 5:016a7315b75d 699 void GameEngine::enemy2_dead(N5110 &lcd, Gamepad &pad){ // animation when the enemy is dead in stage two
RexRoshan 0:99fa5a619081 700
RexRoshan 5:016a7315b75d 701 int e21_health = _e21.get_health(); // Gets the health of the first enemy
RexRoshan 5:016a7315b75d 702 int e22_health = _e22.get_health(); // Gets the health of the second enemy
RexRoshan 0:99fa5a619081 703
RexRoshan 5:016a7315b75d 704 Vector2D e21_pos = _e21.get_enemy21_pos(); // Gets the position of the first enemy
RexRoshan 5:016a7315b75d 705 Vector2D e22_pos = _e22.get_enemy22_pos(); // Gets the position of the second enemy
RexRoshan 0:99fa5a619081 706
RexRoshan 5:016a7315b75d 707 if ((e21_health >= 10) && (e22_health >= 10)){
RexRoshan 5:016a7315b75d 708 // explodes and outputs sound if the enemy is dead
RexRoshan 0:99fa5a619081 709 lcd.drawSprite(e21_pos.x-10,e21_pos.y-10,23,23,(int *)explosion);
RexRoshan 0:99fa5a619081 710 lcd.drawSprite(e22_pos.x-10,e22_pos.y-10,23,23,(int *)explosion);
RexRoshan 0:99fa5a619081 711 pad.tone(1000.0,0.5);
RexRoshan 0:99fa5a619081 712 pad.tone(800.0,0.5);
RexRoshan 0:99fa5a619081 713 pad.tone(600.0,0.5);
RexRoshan 0:99fa5a619081 714 pad.tone(400.0,0.5);
RexRoshan 0:99fa5a619081 715 wait(0.2);
RexRoshan 0:99fa5a619081 716 lcd.drawSprite(e21_pos.x-10,e21_pos.y-10,23,23,(int *)explosion);
RexRoshan 0:99fa5a619081 717 lcd.drawSprite(e22_pos.x-10,e22_pos.y-10,23,23,(int *)explosion);
RexRoshan 5:016a7315b75d 718 _stage = 4; // mission two pass
RexRoshan 0:99fa5a619081 719 lcd.refresh();
RexRoshan 0:99fa5a619081 720 }
RexRoshan 0:99fa5a619081 721
RexRoshan 0:99fa5a619081 722 }
RexRoshan 1:45493d1d0689 723
RexRoshan 5:016a7315b75d 724 void GameEngine::enemy3_dead(N5110 &lcd, Gamepad &pad){ // animation when the enemy is dead in stage three
RexRoshan 5:016a7315b75d 725
RexRoshan 5:016a7315b75d 726 int e3boss_health = _e3.get_health_boss(); // Gets the health of the boss enemy
RexRoshan 5:016a7315b75d 727 int e31_health = _e3.get_health_enemy1(); // Gets the health of the first enemy
RexRoshan 5:016a7315b75d 728 int e32_health = _e3.get_health_enemy2(); // Gets the health of the second enemy
RexRoshan 1:45493d1d0689 729
RexRoshan 5:016a7315b75d 730 Vector2D e3boss_pos = _e3.get_enemyboss_pos(); // Gets the position of the boss enemy
RexRoshan 5:016a7315b75d 731 Vector2D e31_pos = _e3.get_enemy1_pos(); // Gets the position of the first enemy
RexRoshan 5:016a7315b75d 732 Vector2D e32_pos = _e3.get_enemy2_pos(); // Gets the position of the second enemy
RexRoshan 1:45493d1d0689 733
RexRoshan 5:016a7315b75d 734 // explodes and outputs sound if the enemy is dead
RexRoshan 1:45493d1d0689 735 if ((e3boss_health >= 10) && (e31_health >= 10) && (e32_health >= 10)){
RexRoshan 1:45493d1d0689 736 lcd.drawSprite(e3boss_pos.x-10,e3boss_pos.y-10,23,23,(int *)explosion);
RexRoshan 1:45493d1d0689 737 lcd.drawSprite(e31_pos.x-10,e31_pos.y-10,23,23,(int *)explosion);
RexRoshan 1:45493d1d0689 738 lcd.drawSprite(e32_pos.x-10,e32_pos.y-10,23,23,(int *)explosion);
RexRoshan 1:45493d1d0689 739 pad.tone(1000.0,0.5);
RexRoshan 1:45493d1d0689 740 pad.tone(800.0,0.5);
RexRoshan 1:45493d1d0689 741 pad.tone(600.0,0.5);
RexRoshan 1:45493d1d0689 742 pad.tone(400.0,0.5);
RexRoshan 1:45493d1d0689 743 wait(0.2);
RexRoshan 1:45493d1d0689 744 lcd.drawSprite(e3boss_pos.x-10,e3boss_pos.y-10,23,23,(int *)explosion);
RexRoshan 1:45493d1d0689 745 lcd.drawSprite(e31_pos.x-10,e31_pos.y-10,23,23,(int *)explosion);
RexRoshan 1:45493d1d0689 746 lcd.drawSprite(e32_pos.x-10,e32_pos.y-10,23,23,(int *)explosion);
RexRoshan 5:016a7315b75d 747 _stage = 6; // mission three pass
RexRoshan 1:45493d1d0689 748 lcd.refresh();
RexRoshan 1:45493d1d0689 749 }
RexRoshan 1:45493d1d0689 750
RexRoshan 1:45493d1d0689 751 }
RexRoshan 1:45493d1d0689 752
RexRoshan 5:016a7315b75d 753 void GameEngine::spacecraft_dead(N5110 &lcd, Gamepad &pad) // animation when the player's spacecraft is dead in stage one
RexRoshan 5:016a7315b75d 754 {
RexRoshan 5:016a7315b75d 755 int p1_health = _p1.get_health(); // Gets the health of the player spacecraft
RexRoshan 5:016a7315b75d 756 Vector2D p1_pos = _p1.get_pos(); // Gets the position of the player's spacecraft
RexRoshan 0:99fa5a619081 757
RexRoshan 0:99fa5a619081 758 if (p1_health == 6){
RexRoshan 0:99fa5a619081 759
RexRoshan 5:016a7315b75d 760 // explodes and outputs sound if the enemy is dead
RexRoshan 0:99fa5a619081 761 lcd.drawSprite(p1_pos.x-5,p1_pos.y-7,23,23,(int *)explosion);
RexRoshan 0:99fa5a619081 762 pad.tone(1000.0,0.5);
RexRoshan 0:99fa5a619081 763 pad.tone(800.0,0.5);
RexRoshan 0:99fa5a619081 764 pad.tone(600.0,0.5);
RexRoshan 0:99fa5a619081 765 pad.tone(400.0,0.5);
RexRoshan 0:99fa5a619081 766 wait(0.5);
RexRoshan 0:99fa5a619081 767 lcd.refresh();
RexRoshan 0:99fa5a619081 768 wait(0.1);
RexRoshan 0:99fa5a619081 769 lcd.drawSprite(p1_pos.x-5,p1_pos.y-7,23,23,(int *)explosion);
RexRoshan 0:99fa5a619081 770 _p1.update_move();
RexRoshan 5:016a7315b75d 771 _stage = 1; // mission one fail
RexRoshan 0:99fa5a619081 772 lcd.refresh();
RexRoshan 0:99fa5a619081 773 }
RexRoshan 0:99fa5a619081 774
RexRoshan 0:99fa5a619081 775 }
RexRoshan 0:99fa5a619081 776
RexRoshan 5:016a7315b75d 777 void GameEngine::spacecraft2_dead(N5110 &lcd, Gamepad &pad) // animation when the player's spacecraft is dead in stage two
RexRoshan 0:99fa5a619081 778 {
RexRoshan 0:99fa5a619081 779
RexRoshan 5:016a7315b75d 780 int p1_health = _p1.get_health(); // Gets the health of the player spacecraft
RexRoshan 5:016a7315b75d 781 Vector2D p1_pos = _p1.get_pos(); // Gets the position of the player's spacecraft
RexRoshan 0:99fa5a619081 782
RexRoshan 0:99fa5a619081 783 if (p1_health == 6){
RexRoshan 0:99fa5a619081 784
RexRoshan 5:016a7315b75d 785 // explodes and outputs sound if the enemy is dead
RexRoshan 1:45493d1d0689 786 lcd.drawSprite(p1_pos.x-5,p1_pos.y-7,23,23,(int *)explosion);
RexRoshan 1:45493d1d0689 787 pad.tone(1000.0,0.5);
RexRoshan 1:45493d1d0689 788 pad.tone(800.0,0.5);
RexRoshan 1:45493d1d0689 789 pad.tone(600.0,0.5);
RexRoshan 1:45493d1d0689 790 pad.tone(400.0,0.5);
RexRoshan 1:45493d1d0689 791 wait(0.5);
RexRoshan 1:45493d1d0689 792 lcd.refresh();
RexRoshan 1:45493d1d0689 793 wait(0.1);
RexRoshan 1:45493d1d0689 794 lcd.drawSprite(p1_pos.x-5,p1_pos.y-7,23,23,(int *)explosion);
RexRoshan 1:45493d1d0689 795 _p1.update_move();
RexRoshan 5:016a7315b75d 796 _stage = 3; // mission two fail
RexRoshan 1:45493d1d0689 797 lcd.refresh();
RexRoshan 1:45493d1d0689 798 }
RexRoshan 1:45493d1d0689 799
RexRoshan 1:45493d1d0689 800 }
RexRoshan 1:45493d1d0689 801
RexRoshan 5:016a7315b75d 802 void GameEngine::spacecraft3_dead(N5110 &lcd, Gamepad &pad) // animation when the player's spacecraft is dead in stage three
RexRoshan 5:016a7315b75d 803 {
RexRoshan 5:016a7315b75d 804 int p1_health = _p1.get_health(); // Gets the health of the player spacecraft
RexRoshan 5:016a7315b75d 805 Vector2D p1_pos = _p1.get_pos(); // Gets the position of the player's spacecraft
RexRoshan 0:99fa5a619081 806
RexRoshan 5:016a7315b75d 807 if (p1_health == 6){
RexRoshan 5:016a7315b75d 808
RexRoshan 5:016a7315b75d 809 // explodes and outputs sound if the enemy is dead
RexRoshan 5:016a7315b75d 810 lcd.drawSprite(p1_pos.x-5,p1_pos.y-7,23,23,(int *)explosion);
RexRoshan 5:016a7315b75d 811 pad.tone(1000.0,0.5);
RexRoshan 5:016a7315b75d 812 pad.tone(800.0,0.5);
RexRoshan 5:016a7315b75d 813 pad.tone(600.0,0.5);
RexRoshan 5:016a7315b75d 814 pad.tone(400.0,0.5);
RexRoshan 5:016a7315b75d 815 wait(0.5);
RexRoshan 5:016a7315b75d 816 lcd.refresh();
RexRoshan 5:016a7315b75d 817 wait(0.1);
RexRoshan 5:016a7315b75d 818 lcd.drawSprite(p1_pos.x-5,p1_pos.y-7,23,23,(int *)explosion);
RexRoshan 5:016a7315b75d 819 _p1.update_move();
RexRoshan 5:016a7315b75d 820 _stage = 5; // mission three fail
RexRoshan 5:016a7315b75d 821 lcd.refresh();
RexRoshan 5:016a7315b75d 822 }
RexRoshan 1:45493d1d0689 823
RexRoshan 1:45493d1d0689 824 }
RexRoshan 0:99fa5a619081 825
RexRoshan 0:99fa5a619081 826 void GameEngine::draw_enemy_health(N5110 &lcd)
RexRoshan 0:99fa5a619081 827 {
RexRoshan 0:99fa5a619081 828 // get health of the enemy
RexRoshan 0:99fa5a619081 829 int e1_health = _e1.get_health();
RexRoshan 0:99fa5a619081 830
RexRoshan 5:016a7315b75d 831 if (e1_health <= 10){
RexRoshan 1:45493d1d0689 832 lcd.drawRect(62,42,20,4,FILL_TRANSPARENT);
RexRoshan 1:45493d1d0689 833 lcd.drawRect(62,42,20-2*e1_health,4,FILL_BLACK);
RexRoshan 3:bf9624e5b0c3 834 }
RexRoshan 3:bf9624e5b0c3 835 else {
RexRoshan 3:bf9624e5b0c3 836 lcd.drawRect(62,42,20,4,FILL_TRANSPARENT);
RexRoshan 3:bf9624e5b0c3 837 }
RexRoshan 0:99fa5a619081 838
RexRoshan 0:99fa5a619081 839
RexRoshan 0:99fa5a619081 840 }
RexRoshan 0:99fa5a619081 841
RexRoshan 0:99fa5a619081 842 void GameEngine::draw_enemy21_health(N5110 &lcd)
RexRoshan 0:99fa5a619081 843 {
RexRoshan 0:99fa5a619081 844 // get health of the enemy
RexRoshan 0:99fa5a619081 845 int e21_health = _e21.get_health();
RexRoshan 0:99fa5a619081 846
RexRoshan 5:016a7315b75d 847 if (e21_health <= 10){
RexRoshan 1:45493d1d0689 848 lcd.drawRect(2,42,20,4,FILL_TRANSPARENT);
RexRoshan 1:45493d1d0689 849 lcd.drawRect(2,42,20-2*e21_health,4,FILL_BLACK);
RexRoshan 0:99fa5a619081 850 }
RexRoshan 0:99fa5a619081 851 else {
RexRoshan 1:45493d1d0689 852 lcd.drawRect(2,42,20,4,FILL_TRANSPARENT);
RexRoshan 0:99fa5a619081 853 }
RexRoshan 0:99fa5a619081 854 }
RexRoshan 0:99fa5a619081 855
RexRoshan 0:99fa5a619081 856 void GameEngine::draw_enemy22_health(N5110 &lcd)
RexRoshan 0:99fa5a619081 857 {
RexRoshan 0:99fa5a619081 858 // get health of the enemy
RexRoshan 0:99fa5a619081 859 int e22_health = _e22.get_health();
RexRoshan 0:99fa5a619081 860
RexRoshan 5:016a7315b75d 861 if (e22_health <= 10){
RexRoshan 1:45493d1d0689 862 lcd.drawRect(62,42,20,4,FILL_TRANSPARENT);
RexRoshan 1:45493d1d0689 863 lcd.drawRect(62,42,20-2*e22_health,4,FILL_BLACK);
RexRoshan 0:99fa5a619081 864 }
RexRoshan 0:99fa5a619081 865 else {
RexRoshan 1:45493d1d0689 866 lcd.drawRect(62,42,20,4,FILL_TRANSPARENT);
RexRoshan 0:99fa5a619081 867 }
RexRoshan 0:99fa5a619081 868
RexRoshan 0:99fa5a619081 869 }
RexRoshan 0:99fa5a619081 870
RexRoshan 1:45493d1d0689 871 void GameEngine::draw_enemyboss_health(N5110 &lcd)
RexRoshan 1:45493d1d0689 872 {
RexRoshan 6:1fcfd331c047 873 // get health of the enemy in stage three
RexRoshan 1:45493d1d0689 874 int e3boss_health = _e3.get_health_boss();
RexRoshan 1:45493d1d0689 875 int e3enemy1_health = _e3.get_health_enemy1();
RexRoshan 1:45493d1d0689 876 int e3enemy2_health = _e3.get_health_enemy2();
RexRoshan 1:45493d1d0689 877
RexRoshan 6:1fcfd331c047 878 if (e3boss_health <= 10){
RexRoshan 1:45493d1d0689 879 lcd.drawRect(62,42,20,4,FILL_TRANSPARENT);
RexRoshan 1:45493d1d0689 880 lcd.drawRect(62,42,20-2*e3boss_health,4,FILL_BLACK);
RexRoshan 1:45493d1d0689 881 }
RexRoshan 1:45493d1d0689 882 else {
RexRoshan 1:45493d1d0689 883 lcd.drawRect(62,42,20,4,FILL_TRANSPARENT);
RexRoshan 1:45493d1d0689 884 }
RexRoshan 5:016a7315b75d 885 if (e3enemy1_health <= 10){
RexRoshan 1:45493d1d0689 886 lcd.drawRect(2,42,20,4,FILL_TRANSPARENT);
RexRoshan 1:45493d1d0689 887 lcd.drawRect(2,42,20-2*e3enemy1_health,4,FILL_BLACK);
RexRoshan 1:45493d1d0689 888 }
RexRoshan 1:45493d1d0689 889 else {
RexRoshan 1:45493d1d0689 890 lcd.drawRect(2,42,20,4,FILL_TRANSPARENT);
RexRoshan 1:45493d1d0689 891 }
RexRoshan 5:016a7315b75d 892 if (e3enemy2_health <= 10){
RexRoshan 1:45493d1d0689 893 lcd.drawRect(62,2,20,4,FILL_TRANSPARENT);
RexRoshan 1:45493d1d0689 894 lcd.drawRect(62,2,20-2*e3enemy2_health,4,FILL_BLACK);
RexRoshan 1:45493d1d0689 895 }
RexRoshan 1:45493d1d0689 896 else {
RexRoshan 1:45493d1d0689 897 lcd.drawRect(62,2,20,4,FILL_TRANSPARENT);
RexRoshan 1:45493d1d0689 898 }
RexRoshan 1:45493d1d0689 899 }
RexRoshan 1:45493d1d0689 900
RexRoshan 0:99fa5a619081 901 void GameEngine::draw_spacecraft_health(Gamepad &pad)
RexRoshan 0:99fa5a619081 902 {
RexRoshan 0:99fa5a619081 903 //get the health of the spacecraft
RexRoshan 0:99fa5a619081 904 int p1_health = _p1.get_health();
RexRoshan 0:99fa5a619081 905
RexRoshan 5:016a7315b75d 906 if (p1_health == 0){ // All the lights are switched on
RexRoshan 0:99fa5a619081 907 pad.leds_on();
RexRoshan 5:016a7315b75d 908
RexRoshan 5:016a7315b75d 909 }else if (p1_health == 1){ // Switches off the left most light
RexRoshan 0:99fa5a619081 910 pad.led(1,0);
RexRoshan 0:99fa5a619081 911 pad.led(2,1);
RexRoshan 0:99fa5a619081 912 pad.led(3,1);
RexRoshan 0:99fa5a619081 913 pad.led(4,1);
RexRoshan 0:99fa5a619081 914 pad.led(5,1);
RexRoshan 0:99fa5a619081 915 pad.led(6,1);
RexRoshan 0:99fa5a619081 916
RexRoshan 5:016a7315b75d 917 }else if (p1_health == 2){ // Switches of the two left most lights
RexRoshan 0:99fa5a619081 918 pad.led(1,0);
RexRoshan 0:99fa5a619081 919 pad.led(2,0);
RexRoshan 0:99fa5a619081 920 pad.led(3,1);
RexRoshan 0:99fa5a619081 921 pad.led(4,1);
RexRoshan 0:99fa5a619081 922 pad.led(5,1);
RexRoshan 0:99fa5a619081 923 pad.led(6,1);
RexRoshan 5:016a7315b75d 924 }else if (p1_health == 3){ // Swtiches of the three left most lights
RexRoshan 0:99fa5a619081 925 pad.led(1,0);
RexRoshan 0:99fa5a619081 926 pad.led(2,0);
RexRoshan 0:99fa5a619081 927 pad.led(3,0);
RexRoshan 0:99fa5a619081 928 pad.led(4,1);
RexRoshan 0:99fa5a619081 929 pad.led(5,1);
RexRoshan 0:99fa5a619081 930 pad.led(6,1);
RexRoshan 0:99fa5a619081 931
RexRoshan 5:016a7315b75d 932 }else if (p1_health == 4){ // Switches off the four left most lights
RexRoshan 0:99fa5a619081 933 pad.led(1,0);
RexRoshan 0:99fa5a619081 934 pad.led(2,0);
RexRoshan 0:99fa5a619081 935 pad.led(3,0);
RexRoshan 0:99fa5a619081 936 pad.led(4,0);
RexRoshan 0:99fa5a619081 937 pad.led(5,1);
RexRoshan 0:99fa5a619081 938 pad.led(6,1);
RexRoshan 0:99fa5a619081 939
RexRoshan 5:016a7315b75d 940 }else if (p1_health == 5){ // Switches the five left most light
RexRoshan 0:99fa5a619081 941 pad.led(1,0);
RexRoshan 0:99fa5a619081 942 pad.led(2,0);
RexRoshan 0:99fa5a619081 943 pad.led(3,0);
RexRoshan 0:99fa5a619081 944 pad.led(4,0);
RexRoshan 0:99fa5a619081 945 pad.led(5,0);
RexRoshan 0:99fa5a619081 946 pad.led(6,1);
RexRoshan 0:99fa5a619081 947
RexRoshan 0:99fa5a619081 948 } else {
RexRoshan 5:016a7315b75d 949 pad.leds_off(); // Switches all the Led light off
RexRoshan 0:99fa5a619081 950 }
RexRoshan 0:99fa5a619081 951
RexRoshan 0:99fa5a619081 952 }
RexRoshan 6:1fcfd331c047 953
RexRoshan 0:99fa5a619081 954 int GameEngine::get_game_stage() {
RexRoshan 0:99fa5a619081 955 int stage = _stage;
RexRoshan 5:016a7315b75d 956 return stage; // Gets the value of the stage
RexRoshan 0:99fa5a619081 957 }
RexRoshan 0:99fa5a619081 958
RexRoshan 0:99fa5a619081 959 int GameEngine::restart_game_stage() {
RexRoshan 5:016a7315b75d 960
RexRoshan 0:99fa5a619081 961 int stage = _stage;
RexRoshan 5:016a7315b75d 962 stage = 0; // sets the stage to be zero
RexRoshan 0:99fa5a619081 963 return stage;
RexRoshan 0:99fa5a619081 964 }