ELEC2645 (2018/19) / Mbed 2 deprecated el17aio

Dependencies:   mbed

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