ELEC2645 (2018/19) / Mbed 2 deprecated el17aio

Dependencies:   mbed

Committer:
ikenna1
Date:
Wed May 08 15:50:40 2019 +0000
Revision:
43:500b8cff3715
Parent:
41:e1fa36c0492e
Child:
44:a6a361bea806
Test Documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ikenna1 3:f9cd1a38d5c6 1 #include "RosenEngine.h"
ikenna1 39:7824f9080f59 2
ikenna1 23:0301effce801 3 DigitalIn A(PTB9);
ikenna1 3:f9cd1a38d5c6 4
ikenna1 2:66a4e5d7a7cd 5 // Constructor
ikenna1 2:66a4e5d7a7cd 6 RosenEngine::RosenEngine()
ikenna1 2:66a4e5d7a7cd 7 {
ikenna1 2:66a4e5d7a7cd 8
ikenna1 2:66a4e5d7a7cd 9 }
ikenna1 2:66a4e5d7a7cd 10 // Destructor
ikenna1 2:66a4e5d7a7cd 11 RosenEngine::~RosenEngine()
ikenna1 2:66a4e5d7a7cd 12 {
ikenna1 2:66a4e5d7a7cd 13
ikenna1 2:66a4e5d7a7cd 14 }
ikenna1 3:f9cd1a38d5c6 15
ikenna1 4:740e14ebbc97 16
ikenna1 9:241a1a7d8527 17 void RosenEngine::init(int ship_width,int ship_height,int ship_speed,int ship_xpos,int ship_ypos)
ikenna1 2:66a4e5d7a7cd 18 {
ikenna1 4:740e14ebbc97 19 // initialise the game parameters
ikenna1 9:241a1a7d8527 20 _ship.init(ship_width,ship_height,ship_speed,ship_xpos,ship_ypos);
ikenna1 39:7824f9080f59 21 _no_shooters = 0;
ikenna1 39:7824f9080f59 22 _no_seekers = 0;
ikenna1 39:7824f9080f59 23 _enemy.init(_no_shooters,_no_seekers);
ikenna1 9:241a1a7d8527 24 _menu.init(16);
ikenna1 21:628fb703188f 25 _health.init(_shipno);
ikenna1 38:4571537238ed 26 _times_run = 0;
ikenna1 38:4571537238ed 27 _score = 0;
ikenna1 38:4571537238ed 28 _dead = false;
ikenna1 39:7824f9080f59 29 _intro = false;
ikenna1 41:e1fa36c0492e 30 _wait_time = 2.25;
ikenna1 13:e114d362186d 31
ikenna1 3:f9cd1a38d5c6 32 }
ikenna1 27:f99249e727fd 33 void RosenEngine::reset()
ikenna1 27:f99249e727fd 34 {
ikenna1 39:7824f9080f59 35 _enemy.init(_no_shooters,_no_seekers);
ikenna1 27:f99249e727fd 36 _health.init(_shipno);
ikenna1 41:e1fa36c0492e 37 _wait_time = 2.25;
ikenna1 38:4571537238ed 38 _times_run = 0;
ikenna1 38:4571537238ed 39 _score = 0;
ikenna1 39:7824f9080f59 40 _no_shooters = 0;
ikenna1 38:4571537238ed 41 _dead = false;
ikenna1 39:7824f9080f59 42 _no_seekers = 0;
ikenna1 27:f99249e727fd 43 }
ikenna1 4:740e14ebbc97 44
ikenna1 5:bb6edc5b5be3 45 void RosenEngine::read_input(Gamepad &pad)
ikenna1 4:740e14ebbc97 46 {
ikenna1 4:740e14ebbc97 47 Vector2D mapped_coord = pad.get_coord();
ikenna1 41:e1fa36c0492e 48 _joystick.x = mapped_coord.x;
ikenna1 41:e1fa36c0492e 49 _joystick.y = mapped_coord.y;
ikenna1 9:241a1a7d8527 50 _d = pad.get_direction();
ikenna1 35:3341f2bd0408 51 wait(0.1);
ikenna1 41:e1fa36c0492e 52 // printf("_joystick.x ,_joystick.y = %f , %f\n",_joystick.x, _joystick.y);
ikenna1 4:740e14ebbc97 53 }
ikenna1 4:740e14ebbc97 54
ikenna1 14:88ca5b1a111a 55 void RosenEngine::draw(N5110 &lcd, Gamepad &pad)
ikenna1 7:ed5870cfb3e0 56 {
ikenna1 31:c7bd3ed16840 57 lcd.drawRect(0,0,78,48,FILL_TRANSPARENT);
ikenna1 27:f99249e727fd 58 _health.draw_health(lcd,_shipno);
ikenna1 18:2cc6898de6b2 59 _health.draw_shields(lcd);
ikenna1 15:009ccc07bb57 60 _enemy.draw_seeker(lcd);
ikenna1 34:6d0786582d81 61 _enemy.draw_shooter(lcd);
ikenna1 34:6d0786582d81 62 _enemy.draw_shw(lcd,pad);
ikenna1 41:e1fa36c0492e 63 draw_ship(lcd,pad);
ikenna1 40:90c7a893d513 64 if(_dead == true) {
ikenna1 40:90c7a893d513 65 game_over(lcd);
ikenna1 38:4571537238ed 66 }
ikenna1 39:7824f9080f59 67 disp_points(lcd);
ikenna1 11:73cd744ffa80 68 }
ikenna1 41:e1fa36c0492e 69 void RosenEngine::draw_ship(N5110 &lcd, Gamepad &pad)
ikenna1 41:e1fa36c0492e 70 {
ikenna1 41:e1fa36c0492e 71 // find the closest enemy (used in orions firing)
ikenna1 41:e1fa36c0492e 72 Vector2D inde = find_closest1();
ikenna1 41:e1fa36c0492e 73 int index = inde.x;
ikenna1 41:e1fa36c0492e 74 Vector2D closest = find_closest2(index);
ikenna1 41:e1fa36c0492e 75 // Draw ships and weapons depending on the ship being used
ikenna1 43:500b8cff3715 76 switch (_shipUsed) {
ikenna1 43:500b8cff3715 77 case kestrel:
ikenna1 41:e1fa36c0492e 78 _ship.set_dimensions(9,6);
ikenna1 43:500b8cff3715 79 _ship.draw_ship(lcd,_shipUsed);
ikenna1 43:500b8cff3715 80 _weapons.draw(lcd,pad,_shipUsed,closest);
ikenna1 41:e1fa36c0492e 81 break;
ikenna1 43:500b8cff3715 82 case imperion:
ikenna1 41:e1fa36c0492e 83 _ship.set_dimensions(7,10);
ikenna1 43:500b8cff3715 84 _ship.draw_ship(lcd,_shipUsed);
ikenna1 43:500b8cff3715 85 _weapons.draw(lcd,pad,_shipUsed,closest);
ikenna1 41:e1fa36c0492e 86 break;
ikenna1 43:500b8cff3715 87 case orion:
ikenna1 41:e1fa36c0492e 88 _ship.set_dimensions(7,10);
ikenna1 43:500b8cff3715 89 _ship.draw_ship(lcd,_shipUsed);
ikenna1 43:500b8cff3715 90 _weapons.draw(lcd,pad,_shipUsed,closest);
ikenna1 41:e1fa36c0492e 91 break;
ikenna1 41:e1fa36c0492e 92 }
ikenna1 43:500b8cff3715 93 printf("_shipUsed = %d\n",_shipUsed);
ikenna1 41:e1fa36c0492e 94 }
ikenna1 7:ed5870cfb3e0 95
ikenna1 7:ed5870cfb3e0 96 void RosenEngine::update(Gamepad &pad)
ikenna1 7:ed5870cfb3e0 97 {
ikenna1 41:e1fa36c0492e 98 _enemy.update_seeker(_shipPos.x, _shipPos.y);
ikenna1 41:e1fa36c0492e 99 _enemy.update_shooter(_shipPos.x, _shipPos.y);
ikenna1 32:098fbc1222cd 100 _enemy.update_shw();
ikenna1 43:500b8cff3715 101 set_shipUsed();
ikenna1 41:e1fa36c0492e 102 update_shooter_weapon(pad);
ikenna1 35:3341f2bd0408 103 shooter_ship_collision(pad);
ikenna1 35:3341f2bd0408 104 seeker_ship_collision(pad);
ikenna1 35:3341f2bd0408 105 shooterw_ship_collision(pad);
ikenna1 35:3341f2bd0408 106 imperionw_seeker_collision(pad);
ikenna1 35:3341f2bd0408 107 kestrelw_shooter_collision(pad);
ikenna1 35:3341f2bd0408 108 imperionw_shooter_collision(pad);
ikenna1 40:90c7a893d513 109 orionw_collision(pad);
ikenna1 36:c25417f0d150 110 check_health();
ikenna1 37:8d8c8cce0bc7 111 rand_no();
ikenna1 38:4571537238ed 112 scaling(timer(12));
ikenna1 40:90c7a893d513 113
ikenna1 7:ed5870cfb3e0 114 }
ikenna1 41:e1fa36c0492e 115 void RosenEngine::update_shooter_weapon(Gamepad &pad)
ikenna1 41:e1fa36c0492e 116 {
ikenna1 43:500b8cff3715 117 if(_shipUsed == kestrel) {
ikenna1 41:e1fa36c0492e 118 _ship.update_ship(_joystick.x,_joystick.y);
ikenna1 41:e1fa36c0492e 119 _weapons.update();
ikenna1 41:e1fa36c0492e 120 kestrelw_seeker_collision(pad);
ikenna1 41:e1fa36c0492e 121 }
ikenna1 41:e1fa36c0492e 122 //printf("if shipno == 0\n");
ikenna1 43:500b8cff3715 123 if(_shipUsed == imperion && A == false) {
ikenna1 41:e1fa36c0492e 124 _ship.update_ship(_joystick.x,_joystick.y);
ikenna1 41:e1fa36c0492e 125 _weapons.update();
ikenna1 41:e1fa36c0492e 126 }
ikenna1 41:e1fa36c0492e 127 //printf("if shipno == 1\n");
ikenna1 43:500b8cff3715 128 if(_shipUsed == orion) {
ikenna1 41:e1fa36c0492e 129 _ship.update_ship(_joystick.x,_joystick.y);
ikenna1 41:e1fa36c0492e 130 _weapons.update();
ikenna1 41:e1fa36c0492e 131 }
ikenna1 41:e1fa36c0492e 132 }
ikenna1 9:241a1a7d8527 133 void RosenEngine::get_pos()
ikenna1 9:241a1a7d8527 134 {
ikenna1 41:e1fa36c0492e 135 _shipPos = _ship.get_pos();
ikenna1 41:e1fa36c0492e 136 _seekerPos[0] = _enemy.get_seekerpos(1);
ikenna1 41:e1fa36c0492e 137 _seekerPos[1] = _enemy.get_seekerpos(2);
ikenna1 41:e1fa36c0492e 138 _seekerPos[2] = _enemy.get_seekerpos(3);
ikenna1 41:e1fa36c0492e 139 _shooterPos[0] = _enemy.get_shooterpos(1);
ikenna1 41:e1fa36c0492e 140 _shooterPos[1] = _enemy.get_shooterpos(2);
ikenna1 41:e1fa36c0492e 141 _shooterPos[2] = _enemy.get_shooterpos(3);
ikenna1 41:e1fa36c0492e 142 _shooterWPos[0] = _enemy.get_shwpos(1);
ikenna1 41:e1fa36c0492e 143 _shooterWPos[1] = _enemy.get_shwpos(2);
ikenna1 41:e1fa36c0492e 144 _shooterWPos[2] = _enemy.get_shwpos(3);
ikenna1 35:3341f2bd0408 145
ikenna1 41:e1fa36c0492e 146 _weapons.init(_shipPos.x, _shipPos.y, _shipWidth);
ikenna1 13:e114d362186d 147 _ycursor = _menu.get_ycursor();
ikenna1 41:e1fa36c0492e 148 set_ship_size();
ikenna1 41:e1fa36c0492e 149 }
ikenna1 41:e1fa36c0492e 150 void RosenEngine::set_ship_size()
ikenna1 41:e1fa36c0492e 151 {
ikenna1 43:500b8cff3715 152 switch (_shipUsed) {
ikenna1 43:500b8cff3715 153 case kestrel:
ikenna1 41:e1fa36c0492e 154 _shipWidth = 9;
ikenna1 41:e1fa36c0492e 155 _shipHeight = 6;
ikenna1 41:e1fa36c0492e 156 break;
ikenna1 43:500b8cff3715 157 case imperion:
ikenna1 41:e1fa36c0492e 158 _shipWidth = 7;
ikenna1 41:e1fa36c0492e 159 _shipHeight = 10;
ikenna1 41:e1fa36c0492e 160 break;
ikenna1 43:500b8cff3715 161 case orion:
ikenna1 41:e1fa36c0492e 162 _shipWidth = 7;
ikenna1 41:e1fa36c0492e 163 _shipHeight = 10;
ikenna1 41:e1fa36c0492e 164 break;
ikenna1 41:e1fa36c0492e 165 }
ikenna1 25:faba9eb44514 166
ikenna1 9:241a1a7d8527 167 }
ikenna1 9:241a1a7d8527 168 void RosenEngine::title(N5110 &lcd)
ikenna1 9:241a1a7d8527 169 {
ikenna1 30:711d722f3cef 170 _menu.title(lcd,_shipno);
ikenna1 10:c33d7593a275 171 _menu.update(_d);
ikenna1 10:c33d7593a275 172 }
ikenna1 13:e114d362186d 173 int RosenEngine::get_ycursor()
ikenna1 10:c33d7593a275 174 {
ikenna1 13:e114d362186d 175 _ycursor = _menu.get_ycursor();
ikenna1 10:c33d7593a275 176 return _ycursor;
ikenna1 12:47578eb9ea73 177 }
ikenna1 21:628fb703188f 178 int RosenEngine::get_shipno()
ikenna1 13:e114d362186d 179 {
ikenna1 21:628fb703188f 180 _shipno = _menu.get_xcursor();
ikenna1 21:628fb703188f 181 return _shipno;
ikenna1 13:e114d362186d 182 }
ikenna1 43:500b8cff3715 183 SHIP RosenEngine::set_shipUsed()
ikenna1 43:500b8cff3715 184 {
ikenna1 43:500b8cff3715 185 int shipno = _menu.get_xcursor();
ikenna1 43:500b8cff3715 186 _shipUsed = (SHIP)shipno;
ikenna1 43:500b8cff3715 187 }
ikenna1 12:47578eb9ea73 188 void RosenEngine::ship_select(N5110 &lcd)
ikenna1 12:47578eb9ea73 189 {
ikenna1 12:47578eb9ea73 190 _menu.update(_d);
ikenna1 12:47578eb9ea73 191 _menu.disp_ships(lcd);
ikenna1 17:e65a9f981834 192 }
ikenna1 35:3341f2bd0408 193 bool RosenEngine::check_collision(int xpos1, int ypos1,int width1,int height1,int xpos2, int ypos2,int width2,int height2)
ikenna1 35:3341f2bd0408 194 {
ikenna1 35:3341f2bd0408 195 // Create arrays of all positions with appropriate height and length
ikenna1 35:3341f2bd0408 196 int xpos1_array[width1];
ikenna1 35:3341f2bd0408 197 int ypos1_array[height1];
ikenna1 35:3341f2bd0408 198 int xpos2_array[width2];
ikenna1 35:3341f2bd0408 199 int ypos2_array[height2];
ikenna1 35:3341f2bd0408 200 bool xcol = false;
ikenna1 35:3341f2bd0408 201 bool ycol = false;
ikenna1 35:3341f2bd0408 202 bool col = false;
ikenna1 35:3341f2bd0408 203 //printf("variables declared\n");
ikenna1 35:3341f2bd0408 204 // Loop through both height and width to get a 2D aray of the sprites position
ikenna1 35:3341f2bd0408 205 for(int cx = 0; cx<width1; cx=cx+1) {
ikenna1 35:3341f2bd0408 206 xpos1_array[cx]= xpos1 + cx;
ikenna1 35:3341f2bd0408 207 for(int nx = 0; nx<width2; nx=nx+1) {
ikenna1 35:3341f2bd0408 208 xpos2_array[nx]= xpos2 + nx;
ikenna1 35:3341f2bd0408 209 if(xpos2_array[nx] == xpos1_array[cx]) {
ikenna1 35:3341f2bd0408 210 xcol = true;
ikenna1 35:3341f2bd0408 211 }
ikenna1 35:3341f2bd0408 212 // printf("xarray = %d,x2array = %d,xcol = %d\n",xpos2_array[nx],xpos1_array[cx],xcol);
ikenna1 35:3341f2bd0408 213 }
ikenna1 35:3341f2bd0408 214 }
ikenna1 35:3341f2bd0408 215 //printf("first loop done\n");
ikenna1 35:3341f2bd0408 216 for(int cy = 0; cy<height1; cy=cy+1) {
ikenna1 35:3341f2bd0408 217 ypos1_array[cy]= ypos1 + cy;
ikenna1 35:3341f2bd0408 218 for(int ny = 0; ny<height2; ny=ny+1) {
ikenna1 35:3341f2bd0408 219 ypos2_array[ny]= ypos2 + ny;
ikenna1 35:3341f2bd0408 220 if(ypos2_array[ny] == ypos1_array[cy]) {
ikenna1 35:3341f2bd0408 221 ycol = true;
ikenna1 35:3341f2bd0408 222 }
ikenna1 35:3341f2bd0408 223 // printf("yarray = %d,y2array = %d,ycol = %d\n",ypos2_array[ny],ypos1_array[cy],ycol);
ikenna1 35:3341f2bd0408 224 }
ikenna1 35:3341f2bd0408 225 }
ikenna1 35:3341f2bd0408 226 // if both the hight and width position values are equal a collision has occured
ikenna1 35:3341f2bd0408 227 col = (xcol & ycol);
ikenna1 35:3341f2bd0408 228 //printf("col gotten, col = %d\n",col);
ikenna1 35:3341f2bd0408 229 return col;
ikenna1 35:3341f2bd0408 230 }
ikenna1 35:3341f2bd0408 231 bool RosenEngine::check_collision1(int xpos1,int width1,int xpos2,int width2)
ikenna1 35:3341f2bd0408 232 {
ikenna1 35:3341f2bd0408 233 // Create arrays of all positions with appropriate height and length
ikenna1 35:3341f2bd0408 234 int xpos1_array[width1];
ikenna1 35:3341f2bd0408 235 int xpos2_array[width2];
ikenna1 35:3341f2bd0408 236 bool xcol = false;
ikenna1 35:3341f2bd0408 237
ikenna1 35:3341f2bd0408 238 for(int cx = 0; cx<width1; cx=cx+1) {
ikenna1 35:3341f2bd0408 239 xpos1_array[cx]= xpos1 + cx;
ikenna1 35:3341f2bd0408 240 for(int nx = 0; nx<width2; nx=nx+1) {
ikenna1 35:3341f2bd0408 241 xpos2_array[nx]= xpos2 + nx;
ikenna1 35:3341f2bd0408 242 if(xpos2_array[nx] == xpos1_array[cx]) {
ikenna1 35:3341f2bd0408 243 xcol = true;
ikenna1 35:3341f2bd0408 244 }
ikenna1 35:3341f2bd0408 245 // printf("xarray = %d,x2array = %d,xcol = %d\n",xpos2_array[nx],xpos1_array[cx],xcol);
ikenna1 35:3341f2bd0408 246 }
ikenna1 35:3341f2bd0408 247 }
ikenna1 35:3341f2bd0408 248 return xcol;
ikenna1 35:3341f2bd0408 249 }
ikenna1 35:3341f2bd0408 250
ikenna1 35:3341f2bd0408 251 void RosenEngine::test()
ikenna1 35:3341f2bd0408 252 {
ikenna1 35:3341f2bd0408 253 bool test;
ikenna1 35:3341f2bd0408 254 test = check_collision(5,5,5,5,5,5,5,5);
ikenna1 35:3341f2bd0408 255 if (test == false) {
ikenna1 35:3341f2bd0408 256 printf("fail\n");
ikenna1 35:3341f2bd0408 257 } else {
ikenna1 35:3341f2bd0408 258 printf("pass\n");
ikenna1 35:3341f2bd0408 259 }
ikenna1 35:3341f2bd0408 260 test = check_collision(0,0,1,1,24,24,1,1);
ikenna1 35:3341f2bd0408 261 if (test == true) {
ikenna1 35:3341f2bd0408 262 printf("fail\n");
ikenna1 35:3341f2bd0408 263 } else {
ikenna1 35:3341f2bd0408 264 printf("pass\n");
ikenna1 35:3341f2bd0408 265 }
ikenna1 35:3341f2bd0408 266 }
ikenna1 35:3341f2bd0408 267 // make function resemble test
ikenna1 35:3341f2bd0408 268
ikenna1 35:3341f2bd0408 269 void RosenEngine::seeker_ship_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 270 {
ikenna1 39:7824f9080f59 271 bool col1,col2,col3;
ikenna1 40:90c7a893d513 272
ikenna1 41:e1fa36c0492e 273 col1 = check_collision(_shipPos.x,_shipPos.y,9,6,_seekerPos[0].x, _seekerPos[0].y,10,7);
ikenna1 41:e1fa36c0492e 274 col2 = check_collision(_shipPos.x,_shipPos.y,9,6,_seekerPos[1].x, _seekerPos[1].y,10,7);
ikenna1 41:e1fa36c0492e 275 col3 = check_collision(_shipPos.x,_shipPos.y,9,6,_seekerPos[2].x, _seekerPos[2].y,10,7);
ikenna1 39:7824f9080f59 276 int sel = 0;
ikenna1 40:90c7a893d513 277
ikenna1 39:7824f9080f59 278 if (col1 == true && _no_seekers >= 1) {
ikenna1 39:7824f9080f59 279 sel = 1;
ikenna1 39:7824f9080f59 280 }
ikenna1 39:7824f9080f59 281 if (col2 == true && _no_seekers >= 2) {
ikenna1 39:7824f9080f59 282 sel = 2;
ikenna1 39:7824f9080f59 283 }
ikenna1 39:7824f9080f59 284 if (col3 == true && _no_seekers >= 3) {
ikenna1 39:7824f9080f59 285 sel = 3;
ikenna1 39:7824f9080f59 286 }
ikenna1 39:7824f9080f59 287 // printf("col1 = %d, col2 = %d, col3 = %d, no_seekers = %d\n",col1,col2,col3,_no_seekers);
ikenna1 40:90c7a893d513 288 if(sel != 0) {
ikenna1 39:7824f9080f59 289 _health.update(5,pad);
ikenna1 39:7824f9080f59 290 _health.seekerh_update(sel,10);
ikenna1 35:3341f2bd0408 291 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 292 wait(0.05);
ikenna1 35:3341f2bd0408 293 }
ikenna1 35:3341f2bd0408 294 }
ikenna1 35:3341f2bd0408 295 void RosenEngine::shooter_ship_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 296 {
ikenna1 39:7824f9080f59 297 bool col1,col2,col3;
ikenna1 39:7824f9080f59 298 int sel = 0;
ikenna1 41:e1fa36c0492e 299 col1 = check_collision(_shipPos.x,_shipPos.y,9,6,_shooterPos[0].x, _shooterPos[1].y,10,7);
ikenna1 41:e1fa36c0492e 300 col2 = check_collision(_shipPos.x,_shipPos.y,9,6,_shooterPos[1].x, _shooterPos[0].y,10,7);
ikenna1 41:e1fa36c0492e 301 col3 = check_collision(_shipPos.x,_shipPos.y,9,6,_shooterPos[2].x, _shooterPos[0].y,10,7);
ikenna1 35:3341f2bd0408 302
ikenna1 39:7824f9080f59 303 if(col1 == true && _no_shooters >= 1) {
ikenna1 39:7824f9080f59 304 sel = 1;
ikenna1 39:7824f9080f59 305 }
ikenna1 39:7824f9080f59 306 if(col2 == true && _no_shooters >= 2) {
ikenna1 39:7824f9080f59 307 sel = 2;
ikenna1 39:7824f9080f59 308 }
ikenna1 39:7824f9080f59 309 if(col3 == true && _no_shooters >= 3) {
ikenna1 39:7824f9080f59 310 sel = 3;
ikenna1 39:7824f9080f59 311 }
ikenna1 40:90c7a893d513 312 if(sel != 0) {
ikenna1 35:3341f2bd0408 313 _health.update(1,pad);
ikenna1 39:7824f9080f59 314 _health.shooterh_update(sel,10);
ikenna1 35:3341f2bd0408 315 pad.tone(500,0.05);
ikenna1 40:90c7a893d513 316 wait(0.05);
ikenna1 35:3341f2bd0408 317 }
ikenna1 35:3341f2bd0408 318 }
ikenna1 35:3341f2bd0408 319 void RosenEngine::shooterw_ship_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 320 {
ikenna1 39:7824f9080f59 321 bool col1,col2,col3;
ikenna1 39:7824f9080f59 322 int sel = 0;
ikenna1 41:e1fa36c0492e 323 col1 = check_collision(_shipPos.x,_shipPos.y,9,6,_shooterWPos[0].x, _shooterWPos[1].y,2,2);
ikenna1 41:e1fa36c0492e 324 col2 = check_collision(_shipPos.x,_shipPos.y,9,6,_shooterWPos[1].x, _shooterWPos[2].y,2,2);
ikenna1 41:e1fa36c0492e 325 col3 = check_collision(_shipPos.x,_shipPos.y,9,6,_shooterWPos[2].x, _shooterWPos[2].y,2,2);
ikenna1 35:3341f2bd0408 326
ikenna1 39:7824f9080f59 327 if(col1 == true && _no_shooters >= 1) {
ikenna1 39:7824f9080f59 328 sel = 1;
ikenna1 39:7824f9080f59 329 }
ikenna1 39:7824f9080f59 330 if(col2 == true && _no_shooters >= 2) {
ikenna1 39:7824f9080f59 331 sel = 2;
ikenna1 39:7824f9080f59 332 }
ikenna1 39:7824f9080f59 333 if(col3 == true && _no_shooters >= 3) {
ikenna1 39:7824f9080f59 334 sel = 3;
ikenna1 39:7824f9080f59 335 }
ikenna1 40:90c7a893d513 336 if(sel != 0) {
ikenna1 35:3341f2bd0408 337 _health.update(1,pad);
ikenna1 35:3341f2bd0408 338 pad.tone(500,0.05);
ikenna1 40:90c7a893d513 339 wait(0.05);
ikenna1 35:3341f2bd0408 340 }
ikenna1 35:3341f2bd0408 341 }
ikenna1 35:3341f2bd0408 342 void RosenEngine::kestrelw_seeker_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 343 {
ikenna1 39:7824f9080f59 344 bool col1, col2, col3;
ikenna1 39:7824f9080f59 345 int sel = 0;
ikenna1 43:500b8cff3715 346 Vector2D missle_pos = _weapons.get_pos(_shipUsed);
ikenna1 41:e1fa36c0492e 347 col1 = check_collision(_seekerPos[0].x,_seekerPos[0].y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 41:e1fa36c0492e 348 col2 = check_collision(_seekerPos[1].x,_seekerPos[1].y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 41:e1fa36c0492e 349 col3 = check_collision(_seekerPos[2].x,_seekerPos[2].y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 39:7824f9080f59 350 if (col1 == true && _no_seekers >= 1) {
ikenna1 39:7824f9080f59 351 sel = 1;
ikenna1 39:7824f9080f59 352 }
ikenna1 39:7824f9080f59 353 if (col2 == true && _no_seekers >= 2) {
ikenna1 39:7824f9080f59 354 sel = 2;
ikenna1 39:7824f9080f59 355 }
ikenna1 39:7824f9080f59 356 if (col3 == true && _no_seekers >= 3) {
ikenna1 39:7824f9080f59 357 sel = 3;
ikenna1 39:7824f9080f59 358 }
ikenna1 40:90c7a893d513 359 if(sel != 0) {
ikenna1 35:3341f2bd0408 360 pad.tone(500,0.05);
ikenna1 39:7824f9080f59 361 _health.seekerh_update(sel,5);
ikenna1 35:3341f2bd0408 362 wait(0.05);
ikenna1 35:3341f2bd0408 363 }
ikenna1 35:3341f2bd0408 364 }
ikenna1 35:3341f2bd0408 365 void RosenEngine::imperionw_seeker_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 366 {
ikenna1 39:7824f9080f59 367 bool col1,col2,col3;
ikenna1 39:7824f9080f59 368 int sel = 0;
ikenna1 43:500b8cff3715 369 if(_shipUsed == imperion) {
ikenna1 41:e1fa36c0492e 370 if(_shipPos.y > _seekerPos[0].y + 6) {
ikenna1 41:e1fa36c0492e 371 col1 = check_collision1(_seekerPos[0].x,9,_shipPos.x + 2,3);
ikenna1 41:e1fa36c0492e 372 if (col1 == true && A == true && _no_seekers >= 1) {
ikenna1 41:e1fa36c0492e 373 sel = 1;
ikenna1 41:e1fa36c0492e 374 }
ikenna1 35:3341f2bd0408 375 }
ikenna1 41:e1fa36c0492e 376 if(_shipPos.y > _seekerPos[1].y + 6) {
ikenna1 41:e1fa36c0492e 377 col2 = check_collision1(_seekerPos[1].x,9,_shipPos.x + 2,3);
ikenna1 41:e1fa36c0492e 378 if (col2 == true && A == true && _no_seekers >= 2) {
ikenna1 41:e1fa36c0492e 379 sel = 2;
ikenna1 41:e1fa36c0492e 380 }
ikenna1 39:7824f9080f59 381 }
ikenna1 41:e1fa36c0492e 382 if(_shipPos.y > _seekerPos[0].y + 6) {
ikenna1 41:e1fa36c0492e 383 col3 = check_collision1(_seekerPos[2].x,9,_shipPos.x + 2,3);
ikenna1 41:e1fa36c0492e 384 if (col3 == true && A == true && _no_seekers >= 3) {
ikenna1 41:e1fa36c0492e 385 sel = 3;
ikenna1 41:e1fa36c0492e 386 }
ikenna1 39:7824f9080f59 387 }
ikenna1 39:7824f9080f59 388 }
ikenna1 40:90c7a893d513 389 if(sel != 0) {
ikenna1 39:7824f9080f59 390 _health.seekerh_update(sel,10);
ikenna1 39:7824f9080f59 391 pad.tone(500,0.05);
ikenna1 39:7824f9080f59 392 wait(0.05);
ikenna1 39:7824f9080f59 393 }
ikenna1 35:3341f2bd0408 394 }
ikenna1 35:3341f2bd0408 395 void RosenEngine::kestrelw_shooter_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 396 {
ikenna1 43:500b8cff3715 397 Vector2D missle_pos = _weapons.get_pos(_shipUsed);
ikenna1 35:3341f2bd0408 398 bool col1, col2, col3;
ikenna1 39:7824f9080f59 399 int sel = 0;
ikenna1 41:e1fa36c0492e 400 col1 = check_collision(_shooterPos[0].x,_shooterPos[0].y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 41:e1fa36c0492e 401 col2 = check_collision(_shooterPos[1].x,_shooterPos[1].y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 41:e1fa36c0492e 402 col3 = check_collision(_shooterPos[2].x,_shooterPos[2].y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 39:7824f9080f59 403 if (col1 == true && _no_shooters >= 1) {
ikenna1 39:7824f9080f59 404 sel = 1;
ikenna1 39:7824f9080f59 405 }
ikenna1 39:7824f9080f59 406 if (col2 == true && _no_shooters >= 2) {
ikenna1 39:7824f9080f59 407 sel = 2;
ikenna1 35:3341f2bd0408 408 }
ikenna1 39:7824f9080f59 409 if (col3 == true && _no_shooters >= 3) {
ikenna1 39:7824f9080f59 410 sel = 3;
ikenna1 39:7824f9080f59 411 }
ikenna1 40:90c7a893d513 412 // printf("col1 = %d,col2 = %d,col3 = %d, no_shooters = %d\n",col1,col2,col3,_no_shooters);
ikenna1 40:90c7a893d513 413 if(sel != 0) {
ikenna1 35:3341f2bd0408 414 pad.tone(500,0.05);
ikenna1 39:7824f9080f59 415 _health.shooterh_update(sel,5);
ikenna1 35:3341f2bd0408 416 wait(0.05);
ikenna1 35:3341f2bd0408 417 }
ikenna1 35:3341f2bd0408 418 }
ikenna1 35:3341f2bd0408 419 void RosenEngine::imperionw_shooter_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 420 {
ikenna1 39:7824f9080f59 421 bool col1,col2,col3;
ikenna1 39:7824f9080f59 422 int sel = 0;
ikenna1 40:90c7a893d513 423 if(_shipno == 1) {
ikenna1 41:e1fa36c0492e 424 if(_shipPos.y > _shooterPos[0].y + 6) {
ikenna1 41:e1fa36c0492e 425 col1 = check_collision1(_shooterPos[0].x,9,_shipPos.x + 2,3);
ikenna1 40:90c7a893d513 426 if (col1 == true && A == true && _no_shooters >= 1) {
ikenna1 40:90c7a893d513 427 sel = 1;
ikenna1 40:90c7a893d513 428 }
ikenna1 40:90c7a893d513 429 }
ikenna1 41:e1fa36c0492e 430 if(_shipPos.y > _shooterPos[1].y + 6) {
ikenna1 41:e1fa36c0492e 431 col2 = check_collision1(_shooterPos[1].x,9,_shipPos.x + 2,3);
ikenna1 40:90c7a893d513 432 if (col2 == true && A == true && _no_shooters >= 2) {
ikenna1 40:90c7a893d513 433 sel = 2;
ikenna1 40:90c7a893d513 434 }
ikenna1 40:90c7a893d513 435 }
ikenna1 41:e1fa36c0492e 436 if(_shipPos.y > _shooterPos[2].y + 6) {
ikenna1 41:e1fa36c0492e 437 col3 = check_collision1(_shooterPos[2].x,9,_shipPos.x + 2,3);
ikenna1 40:90c7a893d513 438 if (col3 == true && A == true && _no_shooters >= 3) {
ikenna1 40:90c7a893d513 439 sel = 3;
ikenna1 40:90c7a893d513 440 }
ikenna1 35:3341f2bd0408 441 }
ikenna1 35:3341f2bd0408 442 }
ikenna1 40:90c7a893d513 443 if(sel != 0) {
ikenna1 39:7824f9080f59 444 _health.shooterh_update(sel,10);
ikenna1 39:7824f9080f59 445 pad.tone(500,0.05);
ikenna1 39:7824f9080f59 446 wait(0.05);
ikenna1 39:7824f9080f59 447 }
ikenna1 36:c25417f0d150 448 }
ikenna1 40:90c7a893d513 449 void RosenEngine::orionw_collision(Gamepad &pad)
ikenna1 40:90c7a893d513 450 {
ikenna1 40:90c7a893d513 451 Vector2D inde = find_closest1();
ikenna1 40:90c7a893d513 452 int index1 = inde.x;
ikenna1 40:90c7a893d513 453 int index2 = inde.x - 3;
ikenna1 40:90c7a893d513 454 int distance = inde.y;
ikenna1 41:e1fa36c0492e 455
ikenna1 41:e1fa36c0492e 456 // enemy 1,2 and 3 are shooters
ikenna1 41:e1fa36c0492e 457 if(_no_shooters >= index1 && A == true && distance < 15) {
ikenna1 40:90c7a893d513 458 _health.shooterh_update(index1,10);
ikenna1 40:90c7a893d513 459 pad.tone(500,0.05);
ikenna1 40:90c7a893d513 460 wait(0.05);
ikenna1 40:90c7a893d513 461 }
ikenna1 41:e1fa36c0492e 462 // enemy 4,5 and 6 are seekers so 3 is subtracted from inde.x to compensate
ikenna1 41:e1fa36c0492e 463 if(_no_seekers >= index2 && A == true && distance < 15) {
ikenna1 40:90c7a893d513 464 _health.seekerh_update(index2,10);
ikenna1 40:90c7a893d513 465 pad.tone(500,0.05);
ikenna1 40:90c7a893d513 466 wait(0.05);
ikenna1 40:90c7a893d513 467 }
ikenna1 41:e1fa36c0492e 468
ikenna1 41:e1fa36c0492e 469
ikenna1 40:90c7a893d513 470 }
ikenna1 40:90c7a893d513 471 void RosenEngine::check_health()
ikenna1 40:90c7a893d513 472 {
ikenna1 41:e1fa36c0492e 473 // check player and enemy health
ikenna1 39:7824f9080f59 474 check_se_health();
ikenna1 39:7824f9080f59 475 check_sh_health();
ikenna1 36:c25417f0d150 476 Vector2D hp = _health.get_hp();
ikenna1 40:90c7a893d513 477 if(hp.x <= 0) {
ikenna1 38:4571537238ed 478 // printf("player deaad\n");
ikenna1 36:c25417f0d150 479 _dead = true;
ikenna1 40:90c7a893d513 480 }
ikenna1 40:90c7a893d513 481
ikenna1 39:7824f9080f59 482 }
ikenna1 39:7824f9080f59 483 void RosenEngine::check_se_health()
ikenna1 39:7824f9080f59 484 {
ikenna1 39:7824f9080f59 485 int sel = 0;
ikenna1 39:7824f9080f59 486 int seeker1_health = _health.get_seekerh(1);
ikenna1 39:7824f9080f59 487 int seeker2_health = _health.get_seekerh(2);
ikenna1 39:7824f9080f59 488 int seeker3_health = _health.get_seekerh(3);
ikenna1 39:7824f9080f59 489 // printf("seeker1_h = %d, seeker2_h = %d, seeker3_h = %d\n",seeker1_health,seeker2_health,seeker3_health);
ikenna1 40:90c7a893d513 490 if(seeker1_health == 0) {
ikenna1 39:7824f9080f59 491 sel = 1;
ikenna1 39:7824f9080f59 492 }
ikenna1 40:90c7a893d513 493 if(seeker2_health == 0) {
ikenna1 39:7824f9080f59 494 sel = 2;
ikenna1 39:7824f9080f59 495 }
ikenna1 40:90c7a893d513 496 if(seeker3_health == 0) {
ikenna1 39:7824f9080f59 497 sel = 3;
ikenna1 39:7824f9080f59 498 }
ikenna1 41:e1fa36c0492e 499 // reset seeker and update score when shooter health goes to zero
ikenna1 40:90c7a893d513 500 if(sel != 0) {
ikenna1 39:7824f9080f59 501 _enemy.reset_seeker(sel);
ikenna1 39:7824f9080f59 502 _health.reset_seekerh(sel);
ikenna1 39:7824f9080f59 503 _score = _score + 10;
ikenna1 39:7824f9080f59 504 }
ikenna1 39:7824f9080f59 505 }
ikenna1 39:7824f9080f59 506 void RosenEngine::check_sh_health()
ikenna1 39:7824f9080f59 507 {
ikenna1 39:7824f9080f59 508 int sel = 0;
ikenna1 39:7824f9080f59 509 int shooter1_health = _health.get_shooterh(1);
ikenna1 39:7824f9080f59 510 int shooter2_health = _health.get_shooterh(2);
ikenna1 39:7824f9080f59 511 int shooter3_health = _health.get_shooterh(3);
ikenna1 40:90c7a893d513 512
ikenna1 40:90c7a893d513 513 if(shooter1_health == 0) {
ikenna1 39:7824f9080f59 514 sel = 1;
ikenna1 39:7824f9080f59 515 }
ikenna1 40:90c7a893d513 516 if(shooter2_health == 0) {
ikenna1 39:7824f9080f59 517 sel = 2;
ikenna1 39:7824f9080f59 518 }
ikenna1 40:90c7a893d513 519 if(shooter3_health == 0) {
ikenna1 39:7824f9080f59 520 sel = 3;
ikenna1 39:7824f9080f59 521 }
ikenna1 41:e1fa36c0492e 522 // reset shooter and update score when shooter health goes to zero
ikenna1 40:90c7a893d513 523 if(sel != 0) {
ikenna1 39:7824f9080f59 524 _enemy.reset_shooter(sel);
ikenna1 39:7824f9080f59 525 _health.reset_shooterh(sel);
ikenna1 39:7824f9080f59 526 _score = _score + 20;
ikenna1 39:7824f9080f59 527 }
ikenna1 37:8d8c8cce0bc7 528 }
ikenna1 37:8d8c8cce0bc7 529 int RosenEngine::rand_no()
ikenna1 37:8d8c8cce0bc7 530 {
ikenna1 41:e1fa36c0492e 531 // seeds and returns a random number using the ctime library
ikenna1 37:8d8c8cce0bc7 532 srand(time(NULL));
ikenna1 37:8d8c8cce0bc7 533 int rand_no = (rand() %45) + 1;
ikenna1 37:8d8c8cce0bc7 534 return rand_no;
ikenna1 38:4571537238ed 535 }
ikenna1 38:4571537238ed 536 float RosenEngine::timer(int fps)
ikenna1 38:4571537238ed 537 {
ikenna1 38:4571537238ed 538 _times_run = _times_run + 1;
ikenna1 38:4571537238ed 539 float time_frame = 1.0f/fps;
ikenna1 40:90c7a893d513 540 float time_elapsed = _times_run * time_frame;
ikenna1 38:4571537238ed 541 // printf("time elapsed = %f,time frame = %f, _times_run = %d\n",time_elapsed,time_frame,_times_run);
ikenna1 38:4571537238ed 542 return time_elapsed;
ikenna1 38:4571537238ed 543 }
ikenna1 38:4571537238ed 544 void RosenEngine::score(int points)
ikenna1 38:4571537238ed 545 {
ikenna1 38:4571537238ed 546 _score = _score + points;
ikenna1 38:4571537238ed 547 }
ikenna1 38:4571537238ed 548 bool RosenEngine::dead()
ikenna1 38:4571537238ed 549 {
ikenna1 38:4571537238ed 550 return _dead;
ikenna1 38:4571537238ed 551 }
ikenna1 38:4571537238ed 552
ikenna1 38:4571537238ed 553 void RosenEngine::scaling(float time_elapsed)
ikenna1 38:4571537238ed 554 {
ikenna1 41:e1fa36c0492e 555 // increases difficulty as game progresses
ikenna1 40:90c7a893d513 556 if(time_elapsed == _wait_time) {
ikenna1 38:4571537238ed 557 _no_shooters = _no_shooters + 1;
ikenna1 40:90c7a893d513 558 _no_seekers = _no_seekers + 1;
ikenna1 38:4571537238ed 559 _enemy.sh_scaling(time_elapsed);
ikenna1 39:7824f9080f59 560 _wait_time = _wait_time + 10.00;
ikenna1 38:4571537238ed 561 }
ikenna1 40:90c7a893d513 562 if(_no_shooters > 3) {
ikenna1 38:4571537238ed 563 _no_shooters = 3;
ikenna1 39:7824f9080f59 564 }
ikenna1 40:90c7a893d513 565 if(_no_seekers > 3) {
ikenna1 39:7824f9080f59 566 _no_seekers = 3;
ikenna1 39:7824f9080f59 567 }
ikenna1 38:4571537238ed 568 _enemy.set_noshooters(_no_shooters);
ikenna1 39:7824f9080f59 569 _enemy.set_noseekers(_no_seekers);
ikenna1 39:7824f9080f59 570 // printf("time_elapsed = %f, no_shooters = %d, wait_time = %f\n",time_elapsed,_no_shooters,_wait_time);
ikenna1 38:4571537238ed 571 }
ikenna1 38:4571537238ed 572 void RosenEngine::game_over(N5110 &lcd)
ikenna1 38:4571537238ed 573 {
ikenna1 41:e1fa36c0492e 574 // Display random tips after every loss
ikenna1 41:e1fa36c0492e 575 _lore.display(lcd,rand_no());
ikenna1 39:7824f9080f59 576 }
ikenna1 39:7824f9080f59 577 void RosenEngine::intro(N5110 &lcd)
ikenna1 39:7824f9080f59 578 {
ikenna1 41:e1fa36c0492e 579 _lore.intro(lcd);
ikenna1 39:7824f9080f59 580 _intro = true;
ikenna1 39:7824f9080f59 581 }
ikenna1 39:7824f9080f59 582 void RosenEngine::disp_points(N5110 &lcd)
ikenna1 39:7824f9080f59 583 {
ikenna1 39:7824f9080f59 584 char buffer[10];
ikenna1 39:7824f9080f59 585 sprintf(buffer,"%d",_score);
ikenna1 39:7824f9080f59 586 lcd.printString(buffer,2,0);
ikenna1 39:7824f9080f59 587 }
ikenna1 40:90c7a893d513 588 Vector2D RosenEngine::get_enemynum()
ikenna1 40:90c7a893d513 589 {
ikenna1 41:e1fa36c0492e 590 // return the number of enemy shooters and seekers currently on play
ikenna1 40:90c7a893d513 591 return{_no_shooters,_no_seekers};
ikenna1 40:90c7a893d513 592 }
ikenna1 40:90c7a893d513 593 int RosenEngine::range(int x1, int y1, float x2, float y2)
ikenna1 40:90c7a893d513 594 {
ikenna1 41:e1fa36c0492e 595 // calculates average distance between two points
ikenna1 40:90c7a893d513 596 float rangex = (abs(x1 - x2));
ikenna1 40:90c7a893d513 597 float rangey = (abs(y1 - y2));
ikenna1 40:90c7a893d513 598 int distance = floor((rangex+rangey)/2);
ikenna1 40:90c7a893d513 599 return distance;
ikenna1 40:90c7a893d513 600 }
ikenna1 40:90c7a893d513 601 Vector2D RosenEngine::find_closest1()
ikenna1 40:90c7a893d513 602 {
ikenna1 40:90c7a893d513 603 // get the distance for all enemies
ikenna1 41:e1fa36c0492e 604 int sh1 = range(_shipPos.x,_shipPos.y,_shooterPos[0].x,_shooterPos[0].y);
ikenna1 41:e1fa36c0492e 605 int sh2 = range(_shipPos.x,_shipPos.y,_shooterPos[1].x,_shooterPos[1].y);
ikenna1 41:e1fa36c0492e 606 int sh3 = range(_shipPos.x,_shipPos.y,_shooterPos[2].x,_shooterPos[2].y);
ikenna1 41:e1fa36c0492e 607 int se1 = range(_shipPos.x,_shipPos.y,_seekerPos[0].x,_seekerPos[0].y);
ikenna1 41:e1fa36c0492e 608 int se2 = range(_shipPos.x,_shipPos.y,_seekerPos[1].x,_seekerPos[1].y);
ikenna1 41:e1fa36c0492e 609 int se3 = range(_shipPos.x,_shipPos.y,_seekerPos[2].x,_seekerPos[2].y);
ikenna1 40:90c7a893d513 610
ikenna1 40:90c7a893d513 611 int close[6] = {sh1,sh2,sh3,se1,se2,se3};
ikenna1 40:90c7a893d513 612 // find index of the smallest element
ikenna1 40:90c7a893d513 613 int index = 0;
ikenna1 40:90c7a893d513 614 int smallest = close[0];
ikenna1 40:90c7a893d513 615 for(int i=0; i<6; i=i+1) {
ikenna1 40:90c7a893d513 616 if(smallest>close[i]) {
ikenna1 40:90c7a893d513 617 smallest=close[i];
ikenna1 40:90c7a893d513 618 index = i;
ikenna1 40:90c7a893d513 619 }
ikenna1 40:90c7a893d513 620 }
ikenna1 41:e1fa36c0492e 621 // return the index, so we know what the closest enemy, and the distance to check its in range
ikenna1 40:90c7a893d513 622 return {(index + 1),smallest};
ikenna1 40:90c7a893d513 623 }
ikenna1 40:90c7a893d513 624 Vector2D RosenEngine::find_closest2(int index)
ikenna1 40:90c7a893d513 625 {
ikenna1 40:90c7a893d513 626 // return the position of the closest enemy
ikenna1 40:90c7a893d513 627 if(index == 1 && _no_shooters >= 1) {
ikenna1 41:e1fa36c0492e 628 return {_shooterPos[0].x,_shooterPos[0].y};
ikenna1 40:90c7a893d513 629 }
ikenna1 40:90c7a893d513 630 if(index == 2 && _no_shooters >= 2) {
ikenna1 41:e1fa36c0492e 631 return {_shooterPos[1].x,_shooterPos[1].y};
ikenna1 40:90c7a893d513 632 }
ikenna1 40:90c7a893d513 633 if(index == 3 && _no_shooters >= 3) {
ikenna1 41:e1fa36c0492e 634 return {_shooterPos[2].x,_shooterPos[2].y};
ikenna1 40:90c7a893d513 635 }
ikenna1 40:90c7a893d513 636 if(index == 4 && _no_seekers >= 1 ) {
ikenna1 41:e1fa36c0492e 637 return {_seekerPos[0].x,_seekerPos[0].y};
ikenna1 40:90c7a893d513 638 }
ikenna1 40:90c7a893d513 639 if(index == 5 && _no_seekers >= 2) {
ikenna1 41:e1fa36c0492e 640 return {_seekerPos[1].x,_seekerPos[1].y};
ikenna1 40:90c7a893d513 641 }
ikenna1 40:90c7a893d513 642 if(index == 6 && _no_seekers >= 3) {
ikenna1 41:e1fa36c0492e 643 return {_seekerPos[2].x,_seekerPos[2].y};
ikenna1 40:90c7a893d513 644 }
ikenna1 40:90c7a893d513 645
ikenna1 40:90c7a893d513 646 }