ELEC2645 (2018/19) / Mbed 2 deprecated el17aio

Dependencies:   mbed

Committer:
ikenna1
Date:
Fri May 03 09:41:53 2019 +0000
Revision:
35:3341f2bd0408
Parent:
34:6d0786582d81
Child:
36:c25417f0d150
Fix all collision issues; ; Collision was formerly done in separately for each case now two dedicated function will be used to check if two sprites collided

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ikenna1 3:f9cd1a38d5c6 1 #include "RosenEngine.h"
ikenna1 23:0301effce801 2 DigitalIn A(PTB9);
ikenna1 3:f9cd1a38d5c6 3
ikenna1 2:66a4e5d7a7cd 4 // Constructor
ikenna1 2:66a4e5d7a7cd 5 RosenEngine::RosenEngine()
ikenna1 2:66a4e5d7a7cd 6 {
ikenna1 2:66a4e5d7a7cd 7
ikenna1 2:66a4e5d7a7cd 8 }
ikenna1 2:66a4e5d7a7cd 9 // Destructor
ikenna1 2:66a4e5d7a7cd 10 RosenEngine::~RosenEngine()
ikenna1 2:66a4e5d7a7cd 11 {
ikenna1 2:66a4e5d7a7cd 12
ikenna1 2:66a4e5d7a7cd 13 }
ikenna1 3:f9cd1a38d5c6 14
ikenna1 4:740e14ebbc97 15
ikenna1 9:241a1a7d8527 16 void RosenEngine::init(int ship_width,int ship_height,int ship_speed,int ship_xpos,int ship_ypos)
ikenna1 2:66a4e5d7a7cd 17 {
ikenna1 4:740e14ebbc97 18 // initialise the game parameters
ikenna1 9:241a1a7d8527 19 _ship.init(ship_width,ship_height,ship_speed,ship_xpos,ship_ypos);
ikenna1 15:009ccc07bb57 20 // place seeker above the ship
ikenna1 34:6d0786582d81 21 _enemy.init(48,0,3);
ikenna1 9:241a1a7d8527 22 _menu.init(16);
ikenna1 21:628fb703188f 23 _health.init(_shipno);
ikenna1 13:e114d362186d 24
ikenna1 3:f9cd1a38d5c6 25 }
ikenna1 27:f99249e727fd 26 void RosenEngine::reset()
ikenna1 27:f99249e727fd 27 {
ikenna1 27:f99249e727fd 28 _health.init(_shipno);
ikenna1 27:f99249e727fd 29 }
ikenna1 4:740e14ebbc97 30
ikenna1 5:bb6edc5b5be3 31 void RosenEngine::read_input(Gamepad &pad)
ikenna1 4:740e14ebbc97 32 {
ikenna1 4:740e14ebbc97 33 Vector2D mapped_coord = pad.get_coord();
ikenna1 8:87a845b8575e 34 _xjoystick = mapped_coord.x;
ikenna1 8:87a845b8575e 35 _yjoystick = mapped_coord.y;
ikenna1 9:241a1a7d8527 36 _d = pad.get_direction();
ikenna1 35:3341f2bd0408 37 wait(0.1);
ikenna1 14:88ca5b1a111a 38 // printf("_xjoystick ,_yjoystick = %f , %f\n",_xjoystick, _yjoystick);
ikenna1 4:740e14ebbc97 39 }
ikenna1 4:740e14ebbc97 40
ikenna1 14:88ca5b1a111a 41 void RosenEngine::draw(N5110 &lcd, Gamepad &pad)
ikenna1 7:ed5870cfb3e0 42 {
ikenna1 31:c7bd3ed16840 43 lcd.drawRect(0,0,78,48,FILL_TRANSPARENT);
ikenna1 27:f99249e727fd 44 _health.draw_health(lcd,_shipno);
ikenna1 18:2cc6898de6b2 45 _health.draw_shields(lcd);
ikenna1 15:009ccc07bb57 46 _enemy.draw_seeker(lcd);
ikenna1 34:6d0786582d81 47 _enemy.draw_shooter(lcd);
ikenna1 34:6d0786582d81 48 _enemy.draw_shw(lcd,pad);
ikenna1 21:628fb703188f 49 if(_shipno == 0) {
ikenna1 14:88ca5b1a111a 50 _ship.set_dimensions(9,6);
ikenna1 26:a53d41adf40b 51 _ship.draw_ship(lcd,_shipno);
ikenna1 23:0301effce801 52 _weapons.draw(lcd,pad,_shipno);
ikenna1 13:e114d362186d 53 }
ikenna1 21:628fb703188f 54 if(_shipno == 1) {
ikenna1 14:88ca5b1a111a 55 _ship.set_dimensions(7,10);
ikenna1 26:a53d41adf40b 56 _ship.draw_ship(lcd,_shipno);
ikenna1 26:a53d41adf40b 57 _weapons.draw(lcd,pad,_shipno);
ikenna1 26:a53d41adf40b 58 }
ikenna1 26:a53d41adf40b 59 if(_shipno == 2) {
ikenna1 26:a53d41adf40b 60 _ship.set_dimensions(7,10);
ikenna1 26:a53d41adf40b 61 _ship.draw_ship(lcd,_shipno);
ikenna1 23:0301effce801 62 _weapons.draw(lcd,pad,_shipno);
ikenna1 13:e114d362186d 63 }
ikenna1 11:73cd744ffa80 64 }
ikenna1 7:ed5870cfb3e0 65
ikenna1 7:ed5870cfb3e0 66 void RosenEngine::update(Gamepad &pad)
ikenna1 7:ed5870cfb3e0 67 {
ikenna1 35:3341f2bd0408 68 _enemy.update_seeker(ship_xpos, ship_ypos);
ikenna1 30:711d722f3cef 69 _enemy.update_shooter(ship_xpos, ship_ypos);
ikenna1 35:3341f2bd0408 70 //printf("update_shooter\n");
ikenna1 32:098fbc1222cd 71 _enemy.update_shw();
ikenna1 21:628fb703188f 72 if(_shipno == 0) {
ikenna1 14:88ca5b1a111a 73 _ship.update_ship(_xjoystick,_yjoystick);
ikenna1 14:88ca5b1a111a 74 _weapons.update();
ikenna1 35:3341f2bd0408 75 kestrelw_seeker_collision(pad);
ikenna1 14:88ca5b1a111a 76 }
ikenna1 35:3341f2bd0408 77 //printf("if shipno == 0\n");
ikenna1 23:0301effce801 78 if(_shipno == 1 && A == false) {
ikenna1 14:88ca5b1a111a 79 _ship.update_ship(_xjoystick,_yjoystick);
ikenna1 14:88ca5b1a111a 80 _weapons.update();
ikenna1 14:88ca5b1a111a 81 }
ikenna1 35:3341f2bd0408 82 //printf("if shipno == 1\n");
ikenna1 27:f99249e727fd 83 if(_shipno == 2) {
ikenna1 27:f99249e727fd 84 _ship.update_ship(_xjoystick,_yjoystick);
ikenna1 27:f99249e727fd 85 _weapons.update();
ikenna1 27:f99249e727fd 86 }
ikenna1 35:3341f2bd0408 87 // test();
ikenna1 35:3341f2bd0408 88 shooter_ship_collision(pad);
ikenna1 35:3341f2bd0408 89 seeker_ship_collision(pad);
ikenna1 35:3341f2bd0408 90 shooterw_ship_collision(pad);
ikenna1 35:3341f2bd0408 91 imperionw_seeker_collision(pad);
ikenna1 35:3341f2bd0408 92 kestrelw_shooter_collision(pad);
ikenna1 35:3341f2bd0408 93 imperionw_shooter_collision(pad);
ikenna1 7:ed5870cfb3e0 94 }
ikenna1 9:241a1a7d8527 95 void RosenEngine::get_pos()
ikenna1 9:241a1a7d8527 96 {
ikenna1 9:241a1a7d8527 97 Vector2D ship_pos = _ship.get_pos();
ikenna1 9:241a1a7d8527 98 ship_xpos = ship_pos.x;
ikenna1 9:241a1a7d8527 99 ship_ypos = ship_pos.y;
ikenna1 35:3341f2bd0408 100
ikenna1 35:3341f2bd0408 101 _shooter1_pos = _enemy.get_shooter1pos();
ikenna1 35:3341f2bd0408 102 _shooter2_pos = _enemy.get_shooter2pos();
ikenna1 35:3341f2bd0408 103 _shooter3_pos = _enemy.get_shooter3pos();
ikenna1 35:3341f2bd0408 104
ikenna1 9:241a1a7d8527 105 _weapons.init(ship_xpos, ship_ypos, ship_width);
ikenna1 13:e114d362186d 106 _ycursor = _menu.get_ycursor();
ikenna1 25:faba9eb44514 107
ikenna1 25:faba9eb44514 108 if(_shipno == 0) {
ikenna1 25:faba9eb44514 109 ship_width = 9;
ikenna1 25:faba9eb44514 110 ship_height = 6;
ikenna1 25:faba9eb44514 111 }
ikenna1 25:faba9eb44514 112 if(_shipno == 1) {
ikenna1 25:faba9eb44514 113 ship_width = 7;
ikenna1 25:faba9eb44514 114 ship_height = 10;
ikenna1 25:faba9eb44514 115 }
ikenna1 9:241a1a7d8527 116 }
ikenna1 9:241a1a7d8527 117 void RosenEngine::title(N5110 &lcd)
ikenna1 9:241a1a7d8527 118 {
ikenna1 30:711d722f3cef 119 _menu.title(lcd,_shipno);
ikenna1 10:c33d7593a275 120 _menu.update(_d);
ikenna1 10:c33d7593a275 121 }
ikenna1 13:e114d362186d 122 int RosenEngine::get_ycursor()
ikenna1 10:c33d7593a275 123 {
ikenna1 13:e114d362186d 124 _ycursor = _menu.get_ycursor();
ikenna1 10:c33d7593a275 125 return _ycursor;
ikenna1 12:47578eb9ea73 126 }
ikenna1 21:628fb703188f 127 int RosenEngine::get_shipno()
ikenna1 13:e114d362186d 128 {
ikenna1 21:628fb703188f 129 _shipno = _menu.get_xcursor();
ikenna1 21:628fb703188f 130 return _shipno;
ikenna1 13:e114d362186d 131 }
ikenna1 12:47578eb9ea73 132 void RosenEngine::ship_select(N5110 &lcd)
ikenna1 12:47578eb9ea73 133 {
ikenna1 12:47578eb9ea73 134 _menu.update(_d);
ikenna1 12:47578eb9ea73 135 _menu.disp_ships(lcd);
ikenna1 17:e65a9f981834 136 }
ikenna1 33:7a814c874c57 137 void RosenEngine::score(int points)
ikenna1 33:7a814c874c57 138 {
ikenna1 30:711d722f3cef 139 _score = _score + points;
ikenna1 35:3341f2bd0408 140 }
ikenna1 35:3341f2bd0408 141 bool RosenEngine::check_collision(int xpos1, int ypos1,int width1,int height1,int xpos2, int ypos2,int width2,int height2)
ikenna1 35:3341f2bd0408 142 {
ikenna1 35:3341f2bd0408 143 // Create arrays of all positions with appropriate height and length
ikenna1 35:3341f2bd0408 144 int xpos1_array[width1];
ikenna1 35:3341f2bd0408 145 int ypos1_array[height1];
ikenna1 35:3341f2bd0408 146 int xpos2_array[width2];
ikenna1 35:3341f2bd0408 147 int ypos2_array[height2];
ikenna1 35:3341f2bd0408 148 bool xcol = false;
ikenna1 35:3341f2bd0408 149 bool ycol = false;
ikenna1 35:3341f2bd0408 150 bool col = false;
ikenna1 35:3341f2bd0408 151 //printf("variables declared\n");
ikenna1 35:3341f2bd0408 152 // Loop through both height and width to get a 2D aray of the sprites position
ikenna1 35:3341f2bd0408 153 for(int cx = 0; cx<width1; cx=cx+1) {
ikenna1 35:3341f2bd0408 154 xpos1_array[cx]= xpos1 + cx;
ikenna1 35:3341f2bd0408 155 for(int nx = 0; nx<width2; nx=nx+1) {
ikenna1 35:3341f2bd0408 156 xpos2_array[nx]= xpos2 + nx;
ikenna1 35:3341f2bd0408 157 if(xpos2_array[nx] == xpos1_array[cx]) {
ikenna1 35:3341f2bd0408 158 xcol = true;
ikenna1 35:3341f2bd0408 159 }
ikenna1 35:3341f2bd0408 160 // printf("xarray = %d,x2array = %d,xcol = %d\n",xpos2_array[nx],xpos1_array[cx],xcol);
ikenna1 35:3341f2bd0408 161 }
ikenna1 35:3341f2bd0408 162 }
ikenna1 35:3341f2bd0408 163 //printf("first loop done\n");
ikenna1 35:3341f2bd0408 164 for(int cy = 0; cy<height1; cy=cy+1) {
ikenna1 35:3341f2bd0408 165 ypos1_array[cy]= ypos1 + cy;
ikenna1 35:3341f2bd0408 166 for(int ny = 0; ny<height2; ny=ny+1) {
ikenna1 35:3341f2bd0408 167 ypos2_array[ny]= ypos2 + ny;
ikenna1 35:3341f2bd0408 168 if(ypos2_array[ny] == ypos1_array[cy]) {
ikenna1 35:3341f2bd0408 169 ycol = true;
ikenna1 35:3341f2bd0408 170 }
ikenna1 35:3341f2bd0408 171 // printf("yarray = %d,y2array = %d,ycol = %d\n",ypos2_array[ny],ypos1_array[cy],ycol);
ikenna1 35:3341f2bd0408 172 }
ikenna1 35:3341f2bd0408 173 }
ikenna1 35:3341f2bd0408 174 //printf("second loop done\n");
ikenna1 35:3341f2bd0408 175 // if both the hight and width position values are equal a collision has occured
ikenna1 35:3341f2bd0408 176 col = (xcol & ycol);
ikenna1 35:3341f2bd0408 177 //printf("col gotten, col = %d\n",col);
ikenna1 35:3341f2bd0408 178 return col;
ikenna1 35:3341f2bd0408 179 }
ikenna1 35:3341f2bd0408 180 bool RosenEngine::check_collision1(int xpos1,int width1,int xpos2,int width2)
ikenna1 35:3341f2bd0408 181 {
ikenna1 35:3341f2bd0408 182 // Create arrays of all positions with appropriate height and length
ikenna1 35:3341f2bd0408 183 int xpos1_array[width1];
ikenna1 35:3341f2bd0408 184 int xpos2_array[width2];
ikenna1 35:3341f2bd0408 185 bool xcol = false;
ikenna1 35:3341f2bd0408 186
ikenna1 35:3341f2bd0408 187 for(int cx = 0; cx<width1; cx=cx+1) {
ikenna1 35:3341f2bd0408 188 xpos1_array[cx]= xpos1 + cx;
ikenna1 35:3341f2bd0408 189 for(int nx = 0; nx<width2; nx=nx+1) {
ikenna1 35:3341f2bd0408 190 xpos2_array[nx]= xpos2 + nx;
ikenna1 35:3341f2bd0408 191 if(xpos2_array[nx] == xpos1_array[cx]) {
ikenna1 35:3341f2bd0408 192 xcol = true;
ikenna1 35:3341f2bd0408 193 }
ikenna1 35:3341f2bd0408 194 // printf("xarray = %d,x2array = %d,xcol = %d\n",xpos2_array[nx],xpos1_array[cx],xcol);
ikenna1 35:3341f2bd0408 195 }
ikenna1 35:3341f2bd0408 196 }
ikenna1 35:3341f2bd0408 197 return xcol;
ikenna1 35:3341f2bd0408 198 }
ikenna1 35:3341f2bd0408 199
ikenna1 35:3341f2bd0408 200 void RosenEngine::test()
ikenna1 35:3341f2bd0408 201 {
ikenna1 35:3341f2bd0408 202 bool test;
ikenna1 35:3341f2bd0408 203 test = check_collision(5,5,5,5,5,5,5,5);
ikenna1 35:3341f2bd0408 204 if (test == false) {
ikenna1 35:3341f2bd0408 205 printf("fail\n");
ikenna1 35:3341f2bd0408 206 } else {
ikenna1 35:3341f2bd0408 207 printf("pass\n");
ikenna1 35:3341f2bd0408 208 }
ikenna1 35:3341f2bd0408 209 test = check_collision(0,0,1,1,24,24,1,1);
ikenna1 35:3341f2bd0408 210 if (test == true) {
ikenna1 35:3341f2bd0408 211 printf("fail\n");
ikenna1 35:3341f2bd0408 212 } else {
ikenna1 35:3341f2bd0408 213 printf("pass\n");
ikenna1 35:3341f2bd0408 214 }
ikenna1 35:3341f2bd0408 215 }
ikenna1 35:3341f2bd0408 216 // make function resemble test
ikenna1 35:3341f2bd0408 217
ikenna1 35:3341f2bd0408 218 void RosenEngine::seeker_ship_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 219 {
ikenna1 35:3341f2bd0408 220 Vector2D seeker_pos = _enemy.get_seekerpos();
ikenna1 35:3341f2bd0408 221 bool collision;
ikenna1 35:3341f2bd0408 222 collision = check_collision(seeker_pos.x,seeker_pos.y,5,5,ship_xpos,ship_ypos,5,5);
ikenna1 35:3341f2bd0408 223 if (collision == true) {
ikenna1 35:3341f2bd0408 224 _health.update(1,pad);
ikenna1 35:3341f2bd0408 225 _enemy.reset_seeker();
ikenna1 35:3341f2bd0408 226 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 227 wait(0.05);
ikenna1 35:3341f2bd0408 228 }
ikenna1 35:3341f2bd0408 229 }
ikenna1 35:3341f2bd0408 230 void RosenEngine::shooter_ship_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 231 {
ikenna1 35:3341f2bd0408 232 bool collision1;
ikenna1 35:3341f2bd0408 233 bool collision2;
ikenna1 35:3341f2bd0408 234 bool collision3;
ikenna1 35:3341f2bd0408 235
ikenna1 35:3341f2bd0408 236 collision1 = check_collision(ship_xpos,ship_ypos,9,6,_shooter1_pos.x, _shooter1_pos.y,10,7);
ikenna1 35:3341f2bd0408 237 collision2 = check_collision(ship_xpos,ship_ypos,9,6,_shooter2_pos.x, _shooter2_pos.y,10,7);
ikenna1 35:3341f2bd0408 238 collision3 = check_collision(ship_xpos,ship_ypos,9,6,_shooter3_pos.x, _shooter3_pos.y,10,7);
ikenna1 35:3341f2bd0408 239
ikenna1 35:3341f2bd0408 240 if(collision1 == true) {
ikenna1 35:3341f2bd0408 241 _health.update(1,pad);
ikenna1 35:3341f2bd0408 242 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 243 wait(0.05);
ikenna1 35:3341f2bd0408 244 }
ikenna1 35:3341f2bd0408 245 if(collision2 == true) {
ikenna1 35:3341f2bd0408 246 _health.update(1,pad);
ikenna1 35:3341f2bd0408 247 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 248 wait(0.05);
ikenna1 35:3341f2bd0408 249 }
ikenna1 35:3341f2bd0408 250 if(collision3 == true) {
ikenna1 35:3341f2bd0408 251 _health.update(1,pad);
ikenna1 35:3341f2bd0408 252 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 253 wait(0.05);
ikenna1 35:3341f2bd0408 254 }
ikenna1 35:3341f2bd0408 255 }
ikenna1 35:3341f2bd0408 256 void RosenEngine::shooterw_ship_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 257 {
ikenna1 35:3341f2bd0408 258 Vector2D _shooterw1_pos = _enemy.get_sh1wpos();
ikenna1 35:3341f2bd0408 259 Vector2D _shooterw2_pos = _enemy.get_sh2wpos();
ikenna1 35:3341f2bd0408 260 Vector2D _shooterw3_pos = _enemy.get_sh3wpos();
ikenna1 35:3341f2bd0408 261
ikenna1 35:3341f2bd0408 262 bool collision1;
ikenna1 35:3341f2bd0408 263 bool collision2;
ikenna1 35:3341f2bd0408 264 bool collision3;
ikenna1 35:3341f2bd0408 265
ikenna1 35:3341f2bd0408 266 collision1 = check_collision(ship_xpos,ship_ypos,9,6,_shooterw1_pos.x, _shooterw1_pos.y,2,2);
ikenna1 35:3341f2bd0408 267 collision2 = check_collision(ship_xpos,ship_ypos,9,6,_shooterw2_pos.x, _shooterw2_pos.y,2,2);
ikenna1 35:3341f2bd0408 268 collision3 = check_collision(ship_xpos,ship_ypos,9,6,_shooterw3_pos.x, _shooterw3_pos.y,2,2);
ikenna1 35:3341f2bd0408 269
ikenna1 35:3341f2bd0408 270 if(collision1 == true) {
ikenna1 35:3341f2bd0408 271 _health.update(1,pad);
ikenna1 35:3341f2bd0408 272 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 273 wait(0.05);
ikenna1 35:3341f2bd0408 274 }
ikenna1 35:3341f2bd0408 275 if(collision2 == true) {
ikenna1 35:3341f2bd0408 276 _health.update(1,pad);
ikenna1 35:3341f2bd0408 277 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 278 wait(0.05);
ikenna1 35:3341f2bd0408 279 }
ikenna1 35:3341f2bd0408 280 if(collision3 == true) {
ikenna1 35:3341f2bd0408 281 _health.update(1,pad);
ikenna1 35:3341f2bd0408 282 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 283 wait(0.05);
ikenna1 35:3341f2bd0408 284 }
ikenna1 35:3341f2bd0408 285 }
ikenna1 35:3341f2bd0408 286 void RosenEngine::kestrelw_seeker_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 287 {
ikenna1 35:3341f2bd0408 288 Vector2D seeker_pos = _enemy.get_seekerpos();
ikenna1 35:3341f2bd0408 289 Vector2D missle_pos = _weapons.get_pos(_shipno);
ikenna1 35:3341f2bd0408 290 bool collision;
ikenna1 35:3341f2bd0408 291 collision = check_collision(seeker_pos.x,seeker_pos.y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 35:3341f2bd0408 292 if (collision == true) {
ikenna1 35:3341f2bd0408 293 _enemy.reset_seeker();
ikenna1 35:3341f2bd0408 294 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 295 wait(0.05);
ikenna1 35:3341f2bd0408 296 }
ikenna1 35:3341f2bd0408 297 }
ikenna1 35:3341f2bd0408 298 void RosenEngine::imperionw_seeker_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 299 {
ikenna1 35:3341f2bd0408 300 Vector2D seeker_pos = _enemy.get_seekerpos();
ikenna1 35:3341f2bd0408 301 bool collision;
ikenna1 35:3341f2bd0408 302 if(ship_ypos > seeker_pos.y + 6) {
ikenna1 35:3341f2bd0408 303 collision = check_collision1(seeker_pos.x,9,ship_xpos + 2,3);
ikenna1 35:3341f2bd0408 304 if (collision == true && A == true) {
ikenna1 35:3341f2bd0408 305 _enemy.reset_seeker();
ikenna1 35:3341f2bd0408 306 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 307 wait(0.05);
ikenna1 35:3341f2bd0408 308 }
ikenna1 35:3341f2bd0408 309 }
ikenna1 35:3341f2bd0408 310 }
ikenna1 35:3341f2bd0408 311 void RosenEngine::kestrelw_shooter_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 312 {
ikenna1 35:3341f2bd0408 313 Vector2D missle_pos = _weapons.get_pos(_shipno);
ikenna1 35:3341f2bd0408 314 bool col1, col2, col3;
ikenna1 35:3341f2bd0408 315 col1 = check_collision(_shooter1_pos.x,_shooter1_pos.y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 35:3341f2bd0408 316 col2 = check_collision(_shooter2_pos.x,_shooter2_pos.y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 35:3341f2bd0408 317 col3 = check_collision(_shooter3_pos.x,_shooter3_pos.y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 35:3341f2bd0408 318 if (col1 == true) {
ikenna1 35:3341f2bd0408 319 _enemy.reset_shooter(1);
ikenna1 35:3341f2bd0408 320 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 321 wait(0.05);
ikenna1 35:3341f2bd0408 322 }
ikenna1 35:3341f2bd0408 323 if (col2 == true) {
ikenna1 35:3341f2bd0408 324 _enemy.reset_shooter(2);
ikenna1 35:3341f2bd0408 325 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 326 wait(0.05);
ikenna1 35:3341f2bd0408 327 }
ikenna1 35:3341f2bd0408 328 if (col3 == true) {
ikenna1 35:3341f2bd0408 329 _enemy.reset_shooter(3);
ikenna1 35:3341f2bd0408 330 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 331 wait(0.05);
ikenna1 35:3341f2bd0408 332 }
ikenna1 35:3341f2bd0408 333 }
ikenna1 35:3341f2bd0408 334 void RosenEngine::imperionw_shooter_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 335 {
ikenna1 35:3341f2bd0408 336 bool col1;
ikenna1 35:3341f2bd0408 337 bool col2;
ikenna1 35:3341f2bd0408 338 bool col3;
ikenna1 35:3341f2bd0408 339 if(ship_ypos > _shooter1_pos.y + 6) {
ikenna1 35:3341f2bd0408 340 col1 = check_collision1(_shooter1_pos.x,9,ship_xpos + 2,3);
ikenna1 35:3341f2bd0408 341 if (col1 == true && A == true) {
ikenna1 35:3341f2bd0408 342 _enemy.reset_shooter(1);
ikenna1 35:3341f2bd0408 343 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 344 wait(0.05);
ikenna1 35:3341f2bd0408 345 }
ikenna1 35:3341f2bd0408 346 }
ikenna1 35:3341f2bd0408 347 if(ship_ypos > _shooter2_pos.y + 6) {
ikenna1 35:3341f2bd0408 348 col2 = check_collision1(_shooter2_pos.x,9,ship_xpos + 2,3);
ikenna1 35:3341f2bd0408 349 if (col2 == true && A == true) {
ikenna1 35:3341f2bd0408 350 _enemy.reset_shooter(2);
ikenna1 35:3341f2bd0408 351 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 352 wait(0.05);
ikenna1 35:3341f2bd0408 353 }
ikenna1 35:3341f2bd0408 354 }
ikenna1 35:3341f2bd0408 355 if(ship_ypos > _shooter3_pos.y + 6) {
ikenna1 35:3341f2bd0408 356 col3 = check_collision1(_shooter3_pos.x,9,ship_xpos + 2,3);
ikenna1 35:3341f2bd0408 357 if (col3 == true && A == true) {
ikenna1 35:3341f2bd0408 358 _enemy.reset_shooter(3);
ikenna1 35:3341f2bd0408 359 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 360 wait(0.05);
ikenna1 35:3341f2bd0408 361 }
ikenna1 35:3341f2bd0408 362 }
ikenna1 18:2cc6898de6b2 363 }