ELEC2645 (2018/19) / Mbed 2 deprecated el17aio

Dependencies:   mbed

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