ELEC2645 (2018/19) / Mbed 2 deprecated el17aio

Dependencies:   mbed

Committer:
ikenna1
Date:
Wed May 08 16:46:21 2019 +0000
Revision:
44:a6a361bea806
Parent:
43:500b8cff3715
Child:
45:fe5fc85a5c73
Add Enum SHIP to make selecting ships easier. started 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 44:a6a361bea806 25 _health.init(_shipUsed);
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 44:a6a361bea806 36 _health.init(_shipUsed);
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 44:a6a361bea806 58 _health.draw_health(lcd,_shipUsed);
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 44:a6a361bea806 170 _menu.title(lcd,_shipUsed);
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 43:500b8cff3715 178 SHIP RosenEngine::set_shipUsed()
ikenna1 43:500b8cff3715 179 {
ikenna1 43:500b8cff3715 180 int shipno = _menu.get_xcursor();
ikenna1 43:500b8cff3715 181 _shipUsed = (SHIP)shipno;
ikenna1 43:500b8cff3715 182 }
ikenna1 12:47578eb9ea73 183 void RosenEngine::ship_select(N5110 &lcd)
ikenna1 12:47578eb9ea73 184 {
ikenna1 12:47578eb9ea73 185 _menu.update(_d);
ikenna1 12:47578eb9ea73 186 _menu.disp_ships(lcd);
ikenna1 17:e65a9f981834 187 }
ikenna1 35:3341f2bd0408 188 bool RosenEngine::check_collision(int xpos1, int ypos1,int width1,int height1,int xpos2, int ypos2,int width2,int height2)
ikenna1 35:3341f2bd0408 189 {
ikenna1 35:3341f2bd0408 190 // Create arrays of all positions with appropriate height and length
ikenna1 35:3341f2bd0408 191 int xpos1_array[width1];
ikenna1 35:3341f2bd0408 192 int ypos1_array[height1];
ikenna1 35:3341f2bd0408 193 int xpos2_array[width2];
ikenna1 35:3341f2bd0408 194 int ypos2_array[height2];
ikenna1 35:3341f2bd0408 195 bool xcol = false;
ikenna1 35:3341f2bd0408 196 bool ycol = false;
ikenna1 35:3341f2bd0408 197 bool col = false;
ikenna1 35:3341f2bd0408 198 //printf("variables declared\n");
ikenna1 35:3341f2bd0408 199 // Loop through both height and width to get a 2D aray of the sprites position
ikenna1 35:3341f2bd0408 200 for(int cx = 0; cx<width1; cx=cx+1) {
ikenna1 35:3341f2bd0408 201 xpos1_array[cx]= xpos1 + cx;
ikenna1 35:3341f2bd0408 202 for(int nx = 0; nx<width2; nx=nx+1) {
ikenna1 35:3341f2bd0408 203 xpos2_array[nx]= xpos2 + nx;
ikenna1 35:3341f2bd0408 204 if(xpos2_array[nx] == xpos1_array[cx]) {
ikenna1 35:3341f2bd0408 205 xcol = true;
ikenna1 35:3341f2bd0408 206 }
ikenna1 35:3341f2bd0408 207 // printf("xarray = %d,x2array = %d,xcol = %d\n",xpos2_array[nx],xpos1_array[cx],xcol);
ikenna1 35:3341f2bd0408 208 }
ikenna1 35:3341f2bd0408 209 }
ikenna1 35:3341f2bd0408 210 //printf("first loop done\n");
ikenna1 35:3341f2bd0408 211 for(int cy = 0; cy<height1; cy=cy+1) {
ikenna1 35:3341f2bd0408 212 ypos1_array[cy]= ypos1 + cy;
ikenna1 35:3341f2bd0408 213 for(int ny = 0; ny<height2; ny=ny+1) {
ikenna1 35:3341f2bd0408 214 ypos2_array[ny]= ypos2 + ny;
ikenna1 35:3341f2bd0408 215 if(ypos2_array[ny] == ypos1_array[cy]) {
ikenna1 35:3341f2bd0408 216 ycol = true;
ikenna1 35:3341f2bd0408 217 }
ikenna1 35:3341f2bd0408 218 // printf("yarray = %d,y2array = %d,ycol = %d\n",ypos2_array[ny],ypos1_array[cy],ycol);
ikenna1 35:3341f2bd0408 219 }
ikenna1 35:3341f2bd0408 220 }
ikenna1 35:3341f2bd0408 221 // if both the hight and width position values are equal a collision has occured
ikenna1 35:3341f2bd0408 222 col = (xcol & ycol);
ikenna1 35:3341f2bd0408 223 //printf("col gotten, col = %d\n",col);
ikenna1 35:3341f2bd0408 224 return col;
ikenna1 35:3341f2bd0408 225 }
ikenna1 35:3341f2bd0408 226 bool RosenEngine::check_collision1(int xpos1,int width1,int xpos2,int width2)
ikenna1 35:3341f2bd0408 227 {
ikenna1 35:3341f2bd0408 228 // Create arrays of all positions with appropriate height and length
ikenna1 35:3341f2bd0408 229 int xpos1_array[width1];
ikenna1 35:3341f2bd0408 230 int xpos2_array[width2];
ikenna1 35:3341f2bd0408 231 bool xcol = false;
ikenna1 35:3341f2bd0408 232
ikenna1 35:3341f2bd0408 233 for(int cx = 0; cx<width1; cx=cx+1) {
ikenna1 35:3341f2bd0408 234 xpos1_array[cx]= xpos1 + cx;
ikenna1 35:3341f2bd0408 235 for(int nx = 0; nx<width2; nx=nx+1) {
ikenna1 35:3341f2bd0408 236 xpos2_array[nx]= xpos2 + nx;
ikenna1 35:3341f2bd0408 237 if(xpos2_array[nx] == xpos1_array[cx]) {
ikenna1 35:3341f2bd0408 238 xcol = true;
ikenna1 35:3341f2bd0408 239 }
ikenna1 35:3341f2bd0408 240 // printf("xarray = %d,x2array = %d,xcol = %d\n",xpos2_array[nx],xpos1_array[cx],xcol);
ikenna1 35:3341f2bd0408 241 }
ikenna1 35:3341f2bd0408 242 }
ikenna1 35:3341f2bd0408 243 return xcol;
ikenna1 35:3341f2bd0408 244 }
ikenna1 35:3341f2bd0408 245
ikenna1 35:3341f2bd0408 246 void RosenEngine::test()
ikenna1 35:3341f2bd0408 247 {
ikenna1 35:3341f2bd0408 248 bool test;
ikenna1 35:3341f2bd0408 249 test = check_collision(5,5,5,5,5,5,5,5);
ikenna1 35:3341f2bd0408 250 if (test == false) {
ikenna1 35:3341f2bd0408 251 printf("fail\n");
ikenna1 35:3341f2bd0408 252 } else {
ikenna1 35:3341f2bd0408 253 printf("pass\n");
ikenna1 35:3341f2bd0408 254 }
ikenna1 35:3341f2bd0408 255 test = check_collision(0,0,1,1,24,24,1,1);
ikenna1 35:3341f2bd0408 256 if (test == true) {
ikenna1 35:3341f2bd0408 257 printf("fail\n");
ikenna1 35:3341f2bd0408 258 } else {
ikenna1 35:3341f2bd0408 259 printf("pass\n");
ikenna1 35:3341f2bd0408 260 }
ikenna1 35:3341f2bd0408 261 }
ikenna1 35:3341f2bd0408 262 // make function resemble test
ikenna1 35:3341f2bd0408 263
ikenna1 35:3341f2bd0408 264 void RosenEngine::seeker_ship_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 265 {
ikenna1 39:7824f9080f59 266 bool col1,col2,col3;
ikenna1 40:90c7a893d513 267
ikenna1 41:e1fa36c0492e 268 col1 = check_collision(_shipPos.x,_shipPos.y,9,6,_seekerPos[0].x, _seekerPos[0].y,10,7);
ikenna1 41:e1fa36c0492e 269 col2 = check_collision(_shipPos.x,_shipPos.y,9,6,_seekerPos[1].x, _seekerPos[1].y,10,7);
ikenna1 41:e1fa36c0492e 270 col3 = check_collision(_shipPos.x,_shipPos.y,9,6,_seekerPos[2].x, _seekerPos[2].y,10,7);
ikenna1 39:7824f9080f59 271 int sel = 0;
ikenna1 40:90c7a893d513 272
ikenna1 39:7824f9080f59 273 if (col1 == true && _no_seekers >= 1) {
ikenna1 39:7824f9080f59 274 sel = 1;
ikenna1 39:7824f9080f59 275 }
ikenna1 39:7824f9080f59 276 if (col2 == true && _no_seekers >= 2) {
ikenna1 39:7824f9080f59 277 sel = 2;
ikenna1 39:7824f9080f59 278 }
ikenna1 39:7824f9080f59 279 if (col3 == true && _no_seekers >= 3) {
ikenna1 39:7824f9080f59 280 sel = 3;
ikenna1 39:7824f9080f59 281 }
ikenna1 39:7824f9080f59 282 // printf("col1 = %d, col2 = %d, col3 = %d, no_seekers = %d\n",col1,col2,col3,_no_seekers);
ikenna1 40:90c7a893d513 283 if(sel != 0) {
ikenna1 39:7824f9080f59 284 _health.update(5,pad);
ikenna1 39:7824f9080f59 285 _health.seekerh_update(sel,10);
ikenna1 35:3341f2bd0408 286 pad.tone(500,0.05);
ikenna1 35:3341f2bd0408 287 wait(0.05);
ikenna1 35:3341f2bd0408 288 }
ikenna1 35:3341f2bd0408 289 }
ikenna1 35:3341f2bd0408 290 void RosenEngine::shooter_ship_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 291 {
ikenna1 39:7824f9080f59 292 bool col1,col2,col3;
ikenna1 39:7824f9080f59 293 int sel = 0;
ikenna1 41:e1fa36c0492e 294 col1 = check_collision(_shipPos.x,_shipPos.y,9,6,_shooterPos[0].x, _shooterPos[1].y,10,7);
ikenna1 41:e1fa36c0492e 295 col2 = check_collision(_shipPos.x,_shipPos.y,9,6,_shooterPos[1].x, _shooterPos[0].y,10,7);
ikenna1 41:e1fa36c0492e 296 col3 = check_collision(_shipPos.x,_shipPos.y,9,6,_shooterPos[2].x, _shooterPos[0].y,10,7);
ikenna1 35:3341f2bd0408 297
ikenna1 39:7824f9080f59 298 if(col1 == true && _no_shooters >= 1) {
ikenna1 39:7824f9080f59 299 sel = 1;
ikenna1 39:7824f9080f59 300 }
ikenna1 39:7824f9080f59 301 if(col2 == true && _no_shooters >= 2) {
ikenna1 39:7824f9080f59 302 sel = 2;
ikenna1 39:7824f9080f59 303 }
ikenna1 39:7824f9080f59 304 if(col3 == true && _no_shooters >= 3) {
ikenna1 39:7824f9080f59 305 sel = 3;
ikenna1 39:7824f9080f59 306 }
ikenna1 40:90c7a893d513 307 if(sel != 0) {
ikenna1 35:3341f2bd0408 308 _health.update(1,pad);
ikenna1 39:7824f9080f59 309 _health.shooterh_update(sel,10);
ikenna1 35:3341f2bd0408 310 pad.tone(500,0.05);
ikenna1 40:90c7a893d513 311 wait(0.05);
ikenna1 35:3341f2bd0408 312 }
ikenna1 35:3341f2bd0408 313 }
ikenna1 35:3341f2bd0408 314 void RosenEngine::shooterw_ship_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 315 {
ikenna1 39:7824f9080f59 316 bool col1,col2,col3;
ikenna1 39:7824f9080f59 317 int sel = 0;
ikenna1 41:e1fa36c0492e 318 col1 = check_collision(_shipPos.x,_shipPos.y,9,6,_shooterWPos[0].x, _shooterWPos[1].y,2,2);
ikenna1 41:e1fa36c0492e 319 col2 = check_collision(_shipPos.x,_shipPos.y,9,6,_shooterWPos[1].x, _shooterWPos[2].y,2,2);
ikenna1 41:e1fa36c0492e 320 col3 = check_collision(_shipPos.x,_shipPos.y,9,6,_shooterWPos[2].x, _shooterWPos[2].y,2,2);
ikenna1 35:3341f2bd0408 321
ikenna1 39:7824f9080f59 322 if(col1 == true && _no_shooters >= 1) {
ikenna1 39:7824f9080f59 323 sel = 1;
ikenna1 39:7824f9080f59 324 }
ikenna1 39:7824f9080f59 325 if(col2 == true && _no_shooters >= 2) {
ikenna1 39:7824f9080f59 326 sel = 2;
ikenna1 39:7824f9080f59 327 }
ikenna1 39:7824f9080f59 328 if(col3 == true && _no_shooters >= 3) {
ikenna1 39:7824f9080f59 329 sel = 3;
ikenna1 39:7824f9080f59 330 }
ikenna1 40:90c7a893d513 331 if(sel != 0) {
ikenna1 35:3341f2bd0408 332 _health.update(1,pad);
ikenna1 35:3341f2bd0408 333 pad.tone(500,0.05);
ikenna1 40:90c7a893d513 334 wait(0.05);
ikenna1 35:3341f2bd0408 335 }
ikenna1 35:3341f2bd0408 336 }
ikenna1 35:3341f2bd0408 337 void RosenEngine::kestrelw_seeker_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 338 {
ikenna1 39:7824f9080f59 339 bool col1, col2, col3;
ikenna1 39:7824f9080f59 340 int sel = 0;
ikenna1 43:500b8cff3715 341 Vector2D missle_pos = _weapons.get_pos(_shipUsed);
ikenna1 41:e1fa36c0492e 342 col1 = check_collision(_seekerPos[0].x,_seekerPos[0].y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 41:e1fa36c0492e 343 col2 = check_collision(_seekerPos[1].x,_seekerPos[1].y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 41:e1fa36c0492e 344 col3 = check_collision(_seekerPos[2].x,_seekerPos[2].y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 39:7824f9080f59 345 if (col1 == true && _no_seekers >= 1) {
ikenna1 39:7824f9080f59 346 sel = 1;
ikenna1 39:7824f9080f59 347 }
ikenna1 39:7824f9080f59 348 if (col2 == true && _no_seekers >= 2) {
ikenna1 39:7824f9080f59 349 sel = 2;
ikenna1 39:7824f9080f59 350 }
ikenna1 39:7824f9080f59 351 if (col3 == true && _no_seekers >= 3) {
ikenna1 39:7824f9080f59 352 sel = 3;
ikenna1 39:7824f9080f59 353 }
ikenna1 40:90c7a893d513 354 if(sel != 0) {
ikenna1 35:3341f2bd0408 355 pad.tone(500,0.05);
ikenna1 39:7824f9080f59 356 _health.seekerh_update(sel,5);
ikenna1 35:3341f2bd0408 357 wait(0.05);
ikenna1 35:3341f2bd0408 358 }
ikenna1 35:3341f2bd0408 359 }
ikenna1 35:3341f2bd0408 360 void RosenEngine::imperionw_seeker_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 361 {
ikenna1 39:7824f9080f59 362 bool col1,col2,col3;
ikenna1 39:7824f9080f59 363 int sel = 0;
ikenna1 43:500b8cff3715 364 if(_shipUsed == imperion) {
ikenna1 41:e1fa36c0492e 365 if(_shipPos.y > _seekerPos[0].y + 6) {
ikenna1 41:e1fa36c0492e 366 col1 = check_collision1(_seekerPos[0].x,9,_shipPos.x + 2,3);
ikenna1 41:e1fa36c0492e 367 if (col1 == true && A == true && _no_seekers >= 1) {
ikenna1 41:e1fa36c0492e 368 sel = 1;
ikenna1 41:e1fa36c0492e 369 }
ikenna1 35:3341f2bd0408 370 }
ikenna1 41:e1fa36c0492e 371 if(_shipPos.y > _seekerPos[1].y + 6) {
ikenna1 41:e1fa36c0492e 372 col2 = check_collision1(_seekerPos[1].x,9,_shipPos.x + 2,3);
ikenna1 41:e1fa36c0492e 373 if (col2 == true && A == true && _no_seekers >= 2) {
ikenna1 41:e1fa36c0492e 374 sel = 2;
ikenna1 41:e1fa36c0492e 375 }
ikenna1 39:7824f9080f59 376 }
ikenna1 41:e1fa36c0492e 377 if(_shipPos.y > _seekerPos[0].y + 6) {
ikenna1 41:e1fa36c0492e 378 col3 = check_collision1(_seekerPos[2].x,9,_shipPos.x + 2,3);
ikenna1 41:e1fa36c0492e 379 if (col3 == true && A == true && _no_seekers >= 3) {
ikenna1 41:e1fa36c0492e 380 sel = 3;
ikenna1 41:e1fa36c0492e 381 }
ikenna1 39:7824f9080f59 382 }
ikenna1 39:7824f9080f59 383 }
ikenna1 40:90c7a893d513 384 if(sel != 0) {
ikenna1 39:7824f9080f59 385 _health.seekerh_update(sel,10);
ikenna1 39:7824f9080f59 386 pad.tone(500,0.05);
ikenna1 39:7824f9080f59 387 wait(0.05);
ikenna1 39:7824f9080f59 388 }
ikenna1 35:3341f2bd0408 389 }
ikenna1 35:3341f2bd0408 390 void RosenEngine::kestrelw_shooter_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 391 {
ikenna1 43:500b8cff3715 392 Vector2D missle_pos = _weapons.get_pos(_shipUsed);
ikenna1 35:3341f2bd0408 393 bool col1, col2, col3;
ikenna1 39:7824f9080f59 394 int sel = 0;
ikenna1 41:e1fa36c0492e 395 col1 = check_collision(_shooterPos[0].x,_shooterPos[0].y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 41:e1fa36c0492e 396 col2 = check_collision(_shooterPos[1].x,_shooterPos[1].y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 41:e1fa36c0492e 397 col3 = check_collision(_shooterPos[2].x,_shooterPos[2].y,9,6,missle_pos.x,missle_pos.y,1,1);
ikenna1 39:7824f9080f59 398 if (col1 == true && _no_shooters >= 1) {
ikenna1 39:7824f9080f59 399 sel = 1;
ikenna1 39:7824f9080f59 400 }
ikenna1 39:7824f9080f59 401 if (col2 == true && _no_shooters >= 2) {
ikenna1 39:7824f9080f59 402 sel = 2;
ikenna1 35:3341f2bd0408 403 }
ikenna1 39:7824f9080f59 404 if (col3 == true && _no_shooters >= 3) {
ikenna1 39:7824f9080f59 405 sel = 3;
ikenna1 39:7824f9080f59 406 }
ikenna1 40:90c7a893d513 407 // printf("col1 = %d,col2 = %d,col3 = %d, no_shooters = %d\n",col1,col2,col3,_no_shooters);
ikenna1 40:90c7a893d513 408 if(sel != 0) {
ikenna1 35:3341f2bd0408 409 pad.tone(500,0.05);
ikenna1 39:7824f9080f59 410 _health.shooterh_update(sel,5);
ikenna1 35:3341f2bd0408 411 wait(0.05);
ikenna1 35:3341f2bd0408 412 }
ikenna1 35:3341f2bd0408 413 }
ikenna1 35:3341f2bd0408 414 void RosenEngine::imperionw_shooter_collision(Gamepad &pad)
ikenna1 35:3341f2bd0408 415 {
ikenna1 39:7824f9080f59 416 bool col1,col2,col3;
ikenna1 39:7824f9080f59 417 int sel = 0;
ikenna1 44:a6a361bea806 418 if(_shipUsed == imperion) {
ikenna1 41:e1fa36c0492e 419 if(_shipPos.y > _shooterPos[0].y + 6) {
ikenna1 41:e1fa36c0492e 420 col1 = check_collision1(_shooterPos[0].x,9,_shipPos.x + 2,3);
ikenna1 40:90c7a893d513 421 if (col1 == true && A == true && _no_shooters >= 1) {
ikenna1 40:90c7a893d513 422 sel = 1;
ikenna1 40:90c7a893d513 423 }
ikenna1 40:90c7a893d513 424 }
ikenna1 41:e1fa36c0492e 425 if(_shipPos.y > _shooterPos[1].y + 6) {
ikenna1 41:e1fa36c0492e 426 col2 = check_collision1(_shooterPos[1].x,9,_shipPos.x + 2,3);
ikenna1 40:90c7a893d513 427 if (col2 == true && A == true && _no_shooters >= 2) {
ikenna1 40:90c7a893d513 428 sel = 2;
ikenna1 40:90c7a893d513 429 }
ikenna1 40:90c7a893d513 430 }
ikenna1 41:e1fa36c0492e 431 if(_shipPos.y > _shooterPos[2].y + 6) {
ikenna1 41:e1fa36c0492e 432 col3 = check_collision1(_shooterPos[2].x,9,_shipPos.x + 2,3);
ikenna1 40:90c7a893d513 433 if (col3 == true && A == true && _no_shooters >= 3) {
ikenna1 40:90c7a893d513 434 sel = 3;
ikenna1 40:90c7a893d513 435 }
ikenna1 35:3341f2bd0408 436 }
ikenna1 35:3341f2bd0408 437 }
ikenna1 40:90c7a893d513 438 if(sel != 0) {
ikenna1 39:7824f9080f59 439 _health.shooterh_update(sel,10);
ikenna1 39:7824f9080f59 440 pad.tone(500,0.05);
ikenna1 39:7824f9080f59 441 wait(0.05);
ikenna1 39:7824f9080f59 442 }
ikenna1 36:c25417f0d150 443 }
ikenna1 40:90c7a893d513 444 void RosenEngine::orionw_collision(Gamepad &pad)
ikenna1 40:90c7a893d513 445 {
ikenna1 40:90c7a893d513 446 Vector2D inde = find_closest1();
ikenna1 40:90c7a893d513 447 int index1 = inde.x;
ikenna1 40:90c7a893d513 448 int index2 = inde.x - 3;
ikenna1 40:90c7a893d513 449 int distance = inde.y;
ikenna1 41:e1fa36c0492e 450
ikenna1 41:e1fa36c0492e 451 // enemy 1,2 and 3 are shooters
ikenna1 41:e1fa36c0492e 452 if(_no_shooters >= index1 && A == true && distance < 15) {
ikenna1 40:90c7a893d513 453 _health.shooterh_update(index1,10);
ikenna1 40:90c7a893d513 454 pad.tone(500,0.05);
ikenna1 40:90c7a893d513 455 wait(0.05);
ikenna1 40:90c7a893d513 456 }
ikenna1 41:e1fa36c0492e 457 // enemy 4,5 and 6 are seekers so 3 is subtracted from inde.x to compensate
ikenna1 41:e1fa36c0492e 458 if(_no_seekers >= index2 && A == true && distance < 15) {
ikenna1 40:90c7a893d513 459 _health.seekerh_update(index2,10);
ikenna1 40:90c7a893d513 460 pad.tone(500,0.05);
ikenna1 40:90c7a893d513 461 wait(0.05);
ikenna1 40:90c7a893d513 462 }
ikenna1 41:e1fa36c0492e 463
ikenna1 41:e1fa36c0492e 464
ikenna1 40:90c7a893d513 465 }
ikenna1 40:90c7a893d513 466 void RosenEngine::check_health()
ikenna1 40:90c7a893d513 467 {
ikenna1 41:e1fa36c0492e 468 // check player and enemy health
ikenna1 39:7824f9080f59 469 check_se_health();
ikenna1 39:7824f9080f59 470 check_sh_health();
ikenna1 36:c25417f0d150 471 Vector2D hp = _health.get_hp();
ikenna1 40:90c7a893d513 472 if(hp.x <= 0) {
ikenna1 38:4571537238ed 473 // printf("player deaad\n");
ikenna1 36:c25417f0d150 474 _dead = true;
ikenna1 40:90c7a893d513 475 }
ikenna1 40:90c7a893d513 476
ikenna1 39:7824f9080f59 477 }
ikenna1 39:7824f9080f59 478 void RosenEngine::check_se_health()
ikenna1 39:7824f9080f59 479 {
ikenna1 39:7824f9080f59 480 int sel = 0;
ikenna1 39:7824f9080f59 481 int seeker1_health = _health.get_seekerh(1);
ikenna1 39:7824f9080f59 482 int seeker2_health = _health.get_seekerh(2);
ikenna1 39:7824f9080f59 483 int seeker3_health = _health.get_seekerh(3);
ikenna1 39:7824f9080f59 484 // printf("seeker1_h = %d, seeker2_h = %d, seeker3_h = %d\n",seeker1_health,seeker2_health,seeker3_health);
ikenna1 40:90c7a893d513 485 if(seeker1_health == 0) {
ikenna1 39:7824f9080f59 486 sel = 1;
ikenna1 39:7824f9080f59 487 }
ikenna1 40:90c7a893d513 488 if(seeker2_health == 0) {
ikenna1 39:7824f9080f59 489 sel = 2;
ikenna1 39:7824f9080f59 490 }
ikenna1 40:90c7a893d513 491 if(seeker3_health == 0) {
ikenna1 39:7824f9080f59 492 sel = 3;
ikenna1 39:7824f9080f59 493 }
ikenna1 41:e1fa36c0492e 494 // reset seeker and update score when shooter health goes to zero
ikenna1 40:90c7a893d513 495 if(sel != 0) {
ikenna1 39:7824f9080f59 496 _enemy.reset_seeker(sel);
ikenna1 39:7824f9080f59 497 _health.reset_seekerh(sel);
ikenna1 39:7824f9080f59 498 _score = _score + 10;
ikenna1 39:7824f9080f59 499 }
ikenna1 39:7824f9080f59 500 }
ikenna1 39:7824f9080f59 501 void RosenEngine::check_sh_health()
ikenna1 39:7824f9080f59 502 {
ikenna1 39:7824f9080f59 503 int sel = 0;
ikenna1 39:7824f9080f59 504 int shooter1_health = _health.get_shooterh(1);
ikenna1 39:7824f9080f59 505 int shooter2_health = _health.get_shooterh(2);
ikenna1 39:7824f9080f59 506 int shooter3_health = _health.get_shooterh(3);
ikenna1 40:90c7a893d513 507
ikenna1 40:90c7a893d513 508 if(shooter1_health == 0) {
ikenna1 39:7824f9080f59 509 sel = 1;
ikenna1 39:7824f9080f59 510 }
ikenna1 40:90c7a893d513 511 if(shooter2_health == 0) {
ikenna1 39:7824f9080f59 512 sel = 2;
ikenna1 39:7824f9080f59 513 }
ikenna1 40:90c7a893d513 514 if(shooter3_health == 0) {
ikenna1 39:7824f9080f59 515 sel = 3;
ikenna1 39:7824f9080f59 516 }
ikenna1 41:e1fa36c0492e 517 // reset shooter and update score when shooter health goes to zero
ikenna1 40:90c7a893d513 518 if(sel != 0) {
ikenna1 39:7824f9080f59 519 _enemy.reset_shooter(sel);
ikenna1 39:7824f9080f59 520 _health.reset_shooterh(sel);
ikenna1 39:7824f9080f59 521 _score = _score + 20;
ikenna1 39:7824f9080f59 522 }
ikenna1 37:8d8c8cce0bc7 523 }
ikenna1 37:8d8c8cce0bc7 524 int RosenEngine::rand_no()
ikenna1 37:8d8c8cce0bc7 525 {
ikenna1 41:e1fa36c0492e 526 // seeds and returns a random number using the ctime library
ikenna1 37:8d8c8cce0bc7 527 srand(time(NULL));
ikenna1 37:8d8c8cce0bc7 528 int rand_no = (rand() %45) + 1;
ikenna1 37:8d8c8cce0bc7 529 return rand_no;
ikenna1 38:4571537238ed 530 }
ikenna1 38:4571537238ed 531 float RosenEngine::timer(int fps)
ikenna1 38:4571537238ed 532 {
ikenna1 38:4571537238ed 533 _times_run = _times_run + 1;
ikenna1 38:4571537238ed 534 float time_frame = 1.0f/fps;
ikenna1 40:90c7a893d513 535 float time_elapsed = _times_run * time_frame;
ikenna1 38:4571537238ed 536 // printf("time elapsed = %f,time frame = %f, _times_run = %d\n",time_elapsed,time_frame,_times_run);
ikenna1 38:4571537238ed 537 return time_elapsed;
ikenna1 38:4571537238ed 538 }
ikenna1 38:4571537238ed 539 void RosenEngine::score(int points)
ikenna1 38:4571537238ed 540 {
ikenna1 38:4571537238ed 541 _score = _score + points;
ikenna1 38:4571537238ed 542 }
ikenna1 38:4571537238ed 543 bool RosenEngine::dead()
ikenna1 38:4571537238ed 544 {
ikenna1 38:4571537238ed 545 return _dead;
ikenna1 38:4571537238ed 546 }
ikenna1 38:4571537238ed 547
ikenna1 38:4571537238ed 548 void RosenEngine::scaling(float time_elapsed)
ikenna1 38:4571537238ed 549 {
ikenna1 41:e1fa36c0492e 550 // increases difficulty as game progresses
ikenna1 40:90c7a893d513 551 if(time_elapsed == _wait_time) {
ikenna1 38:4571537238ed 552 _no_shooters = _no_shooters + 1;
ikenna1 40:90c7a893d513 553 _no_seekers = _no_seekers + 1;
ikenna1 38:4571537238ed 554 _enemy.sh_scaling(time_elapsed);
ikenna1 39:7824f9080f59 555 _wait_time = _wait_time + 10.00;
ikenna1 38:4571537238ed 556 }
ikenna1 40:90c7a893d513 557 if(_no_shooters > 3) {
ikenna1 38:4571537238ed 558 _no_shooters = 3;
ikenna1 39:7824f9080f59 559 }
ikenna1 40:90c7a893d513 560 if(_no_seekers > 3) {
ikenna1 39:7824f9080f59 561 _no_seekers = 3;
ikenna1 39:7824f9080f59 562 }
ikenna1 38:4571537238ed 563 _enemy.set_noshooters(_no_shooters);
ikenna1 39:7824f9080f59 564 _enemy.set_noseekers(_no_seekers);
ikenna1 39:7824f9080f59 565 // printf("time_elapsed = %f, no_shooters = %d, wait_time = %f\n",time_elapsed,_no_shooters,_wait_time);
ikenna1 38:4571537238ed 566 }
ikenna1 38:4571537238ed 567 void RosenEngine::game_over(N5110 &lcd)
ikenna1 38:4571537238ed 568 {
ikenna1 41:e1fa36c0492e 569 // Display random tips after every loss
ikenna1 41:e1fa36c0492e 570 _lore.display(lcd,rand_no());
ikenna1 39:7824f9080f59 571 }
ikenna1 39:7824f9080f59 572 void RosenEngine::intro(N5110 &lcd)
ikenna1 39:7824f9080f59 573 {
ikenna1 41:e1fa36c0492e 574 _lore.intro(lcd);
ikenna1 39:7824f9080f59 575 _intro = true;
ikenna1 39:7824f9080f59 576 }
ikenna1 39:7824f9080f59 577 void RosenEngine::disp_points(N5110 &lcd)
ikenna1 39:7824f9080f59 578 {
ikenna1 39:7824f9080f59 579 char buffer[10];
ikenna1 39:7824f9080f59 580 sprintf(buffer,"%d",_score);
ikenna1 39:7824f9080f59 581 lcd.printString(buffer,2,0);
ikenna1 39:7824f9080f59 582 }
ikenna1 40:90c7a893d513 583 Vector2D RosenEngine::get_enemynum()
ikenna1 40:90c7a893d513 584 {
ikenna1 41:e1fa36c0492e 585 // return the number of enemy shooters and seekers currently on play
ikenna1 40:90c7a893d513 586 return{_no_shooters,_no_seekers};
ikenna1 40:90c7a893d513 587 }
ikenna1 40:90c7a893d513 588 int RosenEngine::range(int x1, int y1, float x2, float y2)
ikenna1 40:90c7a893d513 589 {
ikenna1 41:e1fa36c0492e 590 // calculates average distance between two points
ikenna1 40:90c7a893d513 591 float rangex = (abs(x1 - x2));
ikenna1 40:90c7a893d513 592 float rangey = (abs(y1 - y2));
ikenna1 40:90c7a893d513 593 int distance = floor((rangex+rangey)/2);
ikenna1 40:90c7a893d513 594 return distance;
ikenna1 40:90c7a893d513 595 }
ikenna1 40:90c7a893d513 596 Vector2D RosenEngine::find_closest1()
ikenna1 40:90c7a893d513 597 {
ikenna1 40:90c7a893d513 598 // get the distance for all enemies
ikenna1 41:e1fa36c0492e 599 int sh1 = range(_shipPos.x,_shipPos.y,_shooterPos[0].x,_shooterPos[0].y);
ikenna1 41:e1fa36c0492e 600 int sh2 = range(_shipPos.x,_shipPos.y,_shooterPos[1].x,_shooterPos[1].y);
ikenna1 41:e1fa36c0492e 601 int sh3 = range(_shipPos.x,_shipPos.y,_shooterPos[2].x,_shooterPos[2].y);
ikenna1 41:e1fa36c0492e 602 int se1 = range(_shipPos.x,_shipPos.y,_seekerPos[0].x,_seekerPos[0].y);
ikenna1 41:e1fa36c0492e 603 int se2 = range(_shipPos.x,_shipPos.y,_seekerPos[1].x,_seekerPos[1].y);
ikenna1 41:e1fa36c0492e 604 int se3 = range(_shipPos.x,_shipPos.y,_seekerPos[2].x,_seekerPos[2].y);
ikenna1 40:90c7a893d513 605
ikenna1 40:90c7a893d513 606 int close[6] = {sh1,sh2,sh3,se1,se2,se3};
ikenna1 40:90c7a893d513 607 // find index of the smallest element
ikenna1 40:90c7a893d513 608 int index = 0;
ikenna1 40:90c7a893d513 609 int smallest = close[0];
ikenna1 40:90c7a893d513 610 for(int i=0; i<6; i=i+1) {
ikenna1 40:90c7a893d513 611 if(smallest>close[i]) {
ikenna1 40:90c7a893d513 612 smallest=close[i];
ikenna1 40:90c7a893d513 613 index = i;
ikenna1 40:90c7a893d513 614 }
ikenna1 40:90c7a893d513 615 }
ikenna1 41:e1fa36c0492e 616 // return the index, so we know what the closest enemy, and the distance to check its in range
ikenna1 40:90c7a893d513 617 return {(index + 1),smallest};
ikenna1 40:90c7a893d513 618 }
ikenna1 40:90c7a893d513 619 Vector2D RosenEngine::find_closest2(int index)
ikenna1 40:90c7a893d513 620 {
ikenna1 40:90c7a893d513 621 // return the position of the closest enemy
ikenna1 40:90c7a893d513 622 if(index == 1 && _no_shooters >= 1) {
ikenna1 41:e1fa36c0492e 623 return {_shooterPos[0].x,_shooterPos[0].y};
ikenna1 40:90c7a893d513 624 }
ikenna1 40:90c7a893d513 625 if(index == 2 && _no_shooters >= 2) {
ikenna1 41:e1fa36c0492e 626 return {_shooterPos[1].x,_shooterPos[1].y};
ikenna1 40:90c7a893d513 627 }
ikenna1 40:90c7a893d513 628 if(index == 3 && _no_shooters >= 3) {
ikenna1 41:e1fa36c0492e 629 return {_shooterPos[2].x,_shooterPos[2].y};
ikenna1 40:90c7a893d513 630 }
ikenna1 40:90c7a893d513 631 if(index == 4 && _no_seekers >= 1 ) {
ikenna1 41:e1fa36c0492e 632 return {_seekerPos[0].x,_seekerPos[0].y};
ikenna1 40:90c7a893d513 633 }
ikenna1 40:90c7a893d513 634 if(index == 5 && _no_seekers >= 2) {
ikenna1 41:e1fa36c0492e 635 return {_seekerPos[1].x,_seekerPos[1].y};
ikenna1 40:90c7a893d513 636 }
ikenna1 40:90c7a893d513 637 if(index == 6 && _no_seekers >= 3) {
ikenna1 41:e1fa36c0492e 638 return {_seekerPos[2].x,_seekerPos[2].y};
ikenna1 40:90c7a893d513 639 }
ikenna1 40:90c7a893d513 640
ikenna1 40:90c7a893d513 641 }