Ikenna Adrian Ozoemena 201157039

Dependencies:   mbed

Revision:
41:e1fa36c0492e
Parent:
40:90c7a893d513
Child:
42:ee13e1d103d8
Child:
45:fe5fc85a5c73
--- a/Enemy/Enemy.cpp	Tue May 07 10:01:34 2019 +0000
+++ b/Enemy/Enemy.cpp	Wed May 08 09:22:16 2019 +0000
@@ -33,29 +33,29 @@
 void Enemy::init(int shno, int seno)
 {
     // initialize seeker
-    _seeker1_xpos = rand_no(68);
-    _seeker1_ypos = 0;
-    _seeker2_xpos = rand_no(68);
-    _seeker2_ypos = 0;
-    _seeker3_xpos = rand_no(68);
-    _seeker3_ypos = 0;
+     _seekerPos[0].x = rand_no(68);
+     _seekerPos[0].y = 0;
+     _seekerPos[1].x = rand_no(68);
+     _seekerPos[1].y = 0;
+     _seekerPos[2].x = rand_no(68);
+     _seekerPos[2].y = 0;
     _seno = seno;
     _shno = shno;
     // initialize shooter
-    _vx1 = 1;
-    _vx2 = 1;
-    _vx3 = 1;
-    _vy1 = 1;
-    _vy2 = 1;
-    _vy3 = 1;
+    _shooterSpeed[0].x = 1;
+    _shooterSpeed[1].x = 1;
+    _shooterSpeed[2].x = 1;
+    _shooterSpeed[0].y = 1;
+    _shooterSpeed[1].y = 1;
+    _shooterSpeed[2].y = 1;
     // for now just starting them spaced apart add randomizer later
 
-    _shooter_xpos1 = rand_no(68);
-    _shooter_ypos1 = 1;
-    _shooter_xpos2 = rand_no(68);
-    _shooter_ypos2 = 1;
-    _shooter_xpos3 = rand_no(68);
-    _shooter_ypos3 = 1;
+    _shooterPos[0].x = rand_no(68);
+    _shooterPos[0].y = 1;
+    _shooterPos[1].x = rand_no(68);
+    _shooterPos[1].y = 1;
+    _shooterPos[2].x = rand_no(68);
+    _shooterPos[2].y = 1;
 
 }
 void Enemy::set_noshooters(int no_shooters)
@@ -67,135 +67,139 @@
     _seno = no_seekers;
 }
 // Draw the ship ***Note: figure out how to change ship type e.g from basic to devotion
-void Enemy::draw_seeker(N5110 &lcd)
-{
-    if(_seno == 1) {
-        lcd.drawSprite(_seeker1_xpos,_seeker1_ypos,7,9,(int *)seeker);
-    }
-    if(_seno == 2) {
-        lcd.drawSprite(_seeker1_xpos,_seeker1_ypos,7,9,(int *)seeker);
-        lcd.drawSprite(_seeker2_xpos,_seeker2_ypos,7,9,(int *)seeker);
-    }
-    if(_seno == 3) {
-        lcd.drawSprite(_seeker1_xpos,_seeker1_ypos,7,9,(int *)seeker);
-        lcd.drawSprite(_seeker2_xpos,_seeker2_ypos,7,9,(int *)seeker);
-        lcd.drawSprite(_seeker3_xpos,_seeker3_ypos,7,9,(int *)seeker);
+void Enemy::draw_seeker(N5110 &lcd)    
+{   
+    switch (_seno) {
+        case 1:
+            lcd.drawSprite( _seekerPos[0].x, _seekerPos[0].y,7,9,(int *)seeker);
+            break;
+        case 2:
+            lcd.drawSprite( _seekerPos[0].x, _seekerPos[0].y,7,9,(int *)seeker);
+            lcd.drawSprite( _seekerPos[1].x, _seekerPos[1].y,7,9,(int *)seeker);
+            break;
+        case 3:
+            lcd.drawSprite( _seekerPos[0].x, _seekerPos[0].y,7,9,(int *)seeker);
+            lcd.drawSprite( _seekerPos[1].x, _seekerPos[1].y,7,9,(int *)seeker);
+            lcd.drawSprite( _seekerPos[2].x, _seekerPos[2].y,7,9,(int *)seeker);
+            break;
     }
 }
 void Enemy::draw_shooter(N5110 &lcd)
 {
-    if(_shno == 1) {
-        lcd.drawSprite(_shooter_xpos1,_shooter_ypos1,10,11,(int *)shooter);
-    }
-    if(_shno == 2) {
-        lcd.drawSprite(_shooter_xpos1,_shooter_ypos1,10,11,(int *)shooter);
-        lcd.drawSprite(_shooter_xpos2,_shooter_ypos2,10,11,(int *)shooter);
+    switch (_shno) {
+        case 1:
+            lcd.drawSprite(_shooterPos[0].x,_shooterPos[0].y,10,11,(int *)shooter);
+            break;
+        case 2:
+            lcd.drawSprite(_shooterPos[0].x,_shooterPos[0].y,10,11,(int *)shooter);
+            lcd.drawSprite(_shooterPos[1].x,_shooterPos[1].y,10,11,(int *)shooter);
+            break;
+        case 3:
+            lcd.drawSprite(_shooterPos[0].x,_shooterPos[0].y,10,11,(int *)shooter);
+            lcd.drawSprite(_shooterPos[1].x,_shooterPos[1].y,10,11,(int *)shooter);
+            lcd.drawSprite(_shooterPos[2].x,_shooterPos[2].y,10,11,(int *)shooter);
+            break;
     }
-    if(_shno == 3) {
-        lcd.drawSprite(_shooter_xpos1,_shooter_ypos1,10,11,(int *)shooter);
-        lcd.drawSprite(_shooter_xpos2,_shooter_ypos2,10,11,(int *)shooter);
-        lcd.drawSprite(_shooter_xpos3,_shooter_ypos3,10,11,(int *)shooter);
-    }
-    // printf("_shno = %d, shooter_xpos1 = %d, shooter_ypos1 = %d/n",_shno,_shooter_xpos1,_shooter_ypos1);
 }
 void Enemy::update_seeker(int ship_xpos, int ship_ypos)
 {
-    if(_seno == 1) {
-        update_seeker1(ship_xpos,ship_ypos);
-    }
-    if(_seno == 2) {
-        update_seeker1(ship_xpos,ship_ypos);
-        update_seeker2(ship_xpos,ship_ypos);
+    switch (_seno) {
+        case 1:
+            update_seeker1(ship_xpos,ship_ypos);
+            break;
+        case 2:
+            update_seeker1(ship_xpos,ship_ypos);
+            update_seeker2(ship_xpos,ship_ypos);
+            break;
+        case 3:
+            update_seeker1(ship_xpos,ship_ypos);
+            update_seeker2(ship_xpos,ship_ypos);
+            update_seeker3(ship_xpos,ship_ypos);
+            break;
     }
-    if(_seno == 3) {
-        update_seeker1(ship_xpos,ship_ypos);
-        update_seeker2(ship_xpos,ship_ypos);
-        update_seeker3(ship_xpos,ship_ypos);
-    }
-    //printf("seno = %d\n",_seno);
 }
 void Enemy::update_seeker1(int ship_xpos, int ship_ypos)
 {
-    int rangex = _seeker1_xpos - ship_xpos;
-    int rangey = _seeker1_ypos - ship_ypos;
+    int rangex =  _seekerPos[0].x - ship_xpos;
+    int rangey =  _seekerPos[0].y - ship_ypos;
 
     // make seeker move towards ship
     if(rangey < 0) {
         if(rangex < 0) {
-            _seeker1_xpos = _seeker1_xpos + 2;
+             _seekerPos[0].x =  _seekerPos[0].x + 2;
         } else if(rangex == 0) {
-            _seeker1_xpos = _seeker1_xpos;
+             _seekerPos[0].x =  _seekerPos[0].x;
         } else {
-            _seeker1_xpos = _seeker1_xpos - 2;
+             _seekerPos[0].x =  _seekerPos[0].x - 2;
         }
     }
 
     // reset seeker to top
-    if(_seeker1_ypos > 54) {
+    if( _seekerPos[0].y > 54) {
         reset_seeker(1);
     }
-    _seeker1_ypos = _seeker1_ypos + 2;
+     _seekerPos[0].y =  _seekerPos[0].y + 2;
     // printf("seeker_xpos , seeker_ypos = %d, %d\n", _seeker_xpos, _seeker_ypos);
 }
 void Enemy::update_seeker2(int ship_xpos, int ship_ypos)
 {
-    int rangex = _seeker2_xpos - ship_xpos;
-    int rangey = _seeker2_ypos - ship_ypos;
+    int rangex =  _seekerPos[1].x - ship_xpos;
+    int rangey =  _seekerPos[1].y - ship_ypos;
 
     // make seeker move towards ship
     if(rangey < 0) {
         if(rangex < 0) {
-            _seeker2_xpos = _seeker2_xpos + 2;
+             _seekerPos[1].x =  _seekerPos[1].x + 2;
         } else if(rangex == 0) {
-            _seeker2_xpos = _seeker2_xpos;
+             _seekerPos[1].x =  _seekerPos[1].x;
         } else {
-            _seeker2_xpos = _seeker2_xpos - 2;
+             _seekerPos[1].x =  _seekerPos[1].x - 2;
         }
     }
 
     // reset seeker to top
-    if(_seeker2_ypos > 54) {
+    if( _seekerPos[1].y > 54) {
         reset_seeker(2);
     }
-    _seeker2_ypos = _seeker2_ypos + 2;
+     _seekerPos[1].y =  _seekerPos[1].y + 2;
     // printf("seeker_xpos , seeker_ypos = %d, %d\n", _seeker_xpos, _seeker_ypos);
 }
 void Enemy::update_seeker3(int ship_xpos, int ship_ypos)
 {
-    int rangex = _seeker3_xpos - ship_xpos;
-    int rangey = _seeker3_ypos - ship_ypos;
+    int rangex =  _seekerPos[2].x - ship_xpos;
+    int rangey =  _seekerPos[2].y - ship_ypos;
 
     // make seeker move towards ship
     if(rangey < 0) {
         if(rangex < 0) {
-            _seeker3_xpos = _seeker3_xpos + 2;
+             _seekerPos[2].x =  _seekerPos[2].x + 2;
         } else if(rangex == 0) {
-            _seeker3_xpos = _seeker3_xpos;
+             _seekerPos[2].x =  _seekerPos[2].x;
         } else {
-            _seeker3_xpos = _seeker3_xpos - 2;
+             _seekerPos[2].x =  _seekerPos[2].x - 2;
         }
     }
 
     // reset seeker to top
-    if(_seeker3_ypos > 54) {
+    if( _seekerPos[2].y > 54) {
         reset_seeker(3);
     }
-    _seeker3_ypos = _seeker3_ypos + 2;
+     _seekerPos[2].y =  _seekerPos[2].y + 2;
     // printf("seeker_xpos , seeker_ypos = %d, %d\n", _seeker_xpos, _seeker_ypos);
 }
 void Enemy::update_shooter(int ship_xpos, int ship_ypos)
 {
-    Vector2D shooter1pos = shooter_motion(_shooter_xpos1,_shooter_ypos1,ship_xpos,ship_ypos,_shwx1,_shwy1,_vx1,_vy1);
-    Vector2D shooter2pos = shooter_motion(_shooter_xpos2,_shooter_ypos2,ship_xpos,ship_ypos,_shwx2,_shwy2,_vx2,_vy2);
-    Vector2D shooter3pos = shooter_motion(_shooter_xpos3,_shooter_ypos3,ship_xpos,ship_ypos,_shwx3,_shwy3,_vx3,_vy3);
+    Vector2D shooter1pos = shooter_motion(_shooterPos[0].x,_shooterPos[0].y,ship_xpos,ship_ypos,_shooterWPos[0].x,_shooterWPos[0].y,_shooterSpeed[0].x,_shooterSpeed[0].y);
+    Vector2D shooter2pos = shooter_motion(_shooterPos[1].x,_shooterPos[1].y,ship_xpos,ship_ypos,_shooterWPos[1].x,_shooterWPos[1].y,_shooterSpeed[1].x,_shooterSpeed[1].y);
+    Vector2D shooter3pos = shooter_motion(_shooterPos[2].x,_shooterPos[2].y,ship_xpos,ship_ypos,_shooterWPos[2].x,_shooterWPos[2].y,_shooterSpeed[2].x,_shooterSpeed[2].y);
     
-    _shooter_xpos1 = shooter1pos.x;
-    _shooter_ypos1 = shooter1pos.y;
-    _shooter_xpos2 = shooter2pos.x;
-    _shooter_ypos2 = shooter2pos.y;
-    _shooter_xpos3 = shooter3pos.x;
-    _shooter_ypos3 = shooter3pos.y;
-    //printf("_shooter_xpos1 = %d,_shooter_ypos1 = %d,projy = %d\n",_shooter_xpos1 ,_shooter_ypos1,_shwy1);
+    _shooterPos[0].x = shooter1pos.x;
+    _shooterPos[0].y = shooter1pos.y;
+    _shooterPos[1].x = shooter2pos.x;
+    _shooterPos[1].y = shooter2pos.y;
+    _shooterPos[2].x = shooter3pos.x;
+    _shooterPos[2].y = shooter3pos.y;
+    //printf("_shooterPos[0].x = %d,_shooterPos[0].y = %d,projy = %d\n",_shooterPos[0].x ,_shooterPos[0].y,_shooterWPos[0]);
 }
 Vector2D Enemy::shooter_motion(int shooter_xpos,int shooter_ypos,int ship_xpos, int ship_ypos, int projx, int projy,int vx, int vy)
 {
@@ -227,7 +231,7 @@
     if(shooter_xpos > 84 - 8 - 11) {
         shooter_xpos = 84 - 8 - 11;
     }
-    //printf("_shooter_xpos1 = %d,_shooter_ypos1 = %d,projy = %d\n",_shooter_xpos1 ,_shooter_ypos1,_shwy1);
+    //printf("_shooterPos[0].x = %d,_shooterPos[0].y = %d,projy = %d\n",_shooterPos[0].x ,_shooterPos[0].y,_shooterWPos[0]);
     // shooter_ypos = shooter_ypos + 1;
     return{shooter_xpos,shooter_ypos};
     
@@ -235,161 +239,162 @@
 
 void Enemy::draw_shw1(N5110 &lcd,Gamepad &pad)
 {
-    _vshw1.x = 0; //Projectile doesn't move sideways.
-    _vshw1.y = 2; //Projectile moves upwards on screen.
+    _shooterWSpeed[0].x = 0; //Projectile doesn't move sideways.
+    _shooterWSpeed[0].y = 2; //Projectile moves upwards on screen.
 
 //resets once projectile reaches bottom of screen
-    if(_shwy1 >= 48) {
-        reset1 = 0;
+    if(_shooterWPos[0].y >= 48) {
+        _reset[0] = 0;
     }
 
-    if(reset1 == 0) {
-        _shwx1 = _shooter_xpos1 + 5;
-        _shwy1 = _shooter_ypos1 + 11;
-        reset1 = reset1 + 1;
+    if(_reset[0] == 0) {
+        _shooterWPos[0].x = _shooterPos[0].x + 5;
+        _shooterWPos[0].y = _shooterPos[0].y + 11;
+        _reset[0] = _reset[0] + 1;
     }
-    lcd.drawRect(_shwx1,_shwy1,1,1,FILL_BLACK);
+    lcd.drawRect(_shooterWPos[0].x,_shooterWPos[0].y,1,1,FILL_BLACK);
 // printf("Ship x and y pos, reset = %d , %d ,%d \n", _ship_xpos, _ship_ypos, reset);
 }
 void Enemy::draw_shw2(N5110 &lcd,Gamepad &pad)
 {
-    _vshw2.x = 0; //Projectile doesn't move sideways.
-    _vshw2.y = 5; //Projectile moves upwards on screen.
+    _shooterWSpeed[1].x = 0; //Projectile doesn't move sideways.
+    _shooterWSpeed[1].y = 5; //Projectile moves upwards on screen.
 
     //resets once projectile reaches bottom of screen
-    if(_shwy2 >= 48) {
-        reset2= 0;
+    if(_shooterWPos[1].y >= 48) {
+        _reset[1]= 0;
     }
 
-    if(reset2 == 0) {
-        _shwx2 = _shooter_xpos2 + 5;
-        _shwy2 = _shooter_ypos2 + 11;
-        reset2 = reset2 + 1;
+    if(_reset[1] == 0) {
+        _shooterWPos[1].x = _shooterPos[1].x + 5;
+        _shooterWPos[1].y = _shooterPos[1].y + 11;
+        _reset[1] = _reset[1] + 1;
     }
-    lcd.drawRect(_shwx2,_shwy2,1,1,FILL_BLACK);
+    lcd.drawRect(_shooterWPos[1].x,_shooterWPos[1].y,1,1,FILL_BLACK);
     // printf("Ship x and y pos, reset = %d , %d ,%d \n", _ship_xpos, _ship_ypos, reset);
 }
 void Enemy::draw_shw3(N5110 &lcd,Gamepad &pad)
 {
-    _vshw3.x = 0; //Projectile doesn't move sideways.
-    _vshw3.y = 3; //Projectile moves upwards on screen.
+    _shooterWSpeed[2].x = 0; //Projectile doesn't move sideways.
+    _shooterWSpeed[2].y = 3; //Projectile moves upwards on screen.
 
     //resets once projectile reaches bottom of screen
-    if(_shwy3 >= 48) {
-        reset3 = 0;
+    if(_shooterWPos[2].y >= 48) {
+        _reset[2] = 0;
     }
 
-    if(reset3 == 0) {
-        _shwx3 = _shooter_xpos3 + 5;
-        _shwy3 = _shooter_ypos3 + 11;
-        reset3 = reset3 + 1;
+    if(_reset[2] == 0) {
+        _shooterWPos[2].x = _shooterPos[2].x + 5;
+        _shooterWPos[2].y = _shooterPos[2].y + 11;
+        _reset[2] = _reset[2] + 1;
     }
-    lcd.drawRect(_shwx3,_shwy3,1,1,FILL_BLACK);
-    // printf("Ship x and y pos, reset = %d , %d ,%d \n", _ship_xpos, _ship_ypos, reset);
+    lcd.drawRect(_shooterWPos[2].x,_shooterWPos[2].y,1,1,FILL_BLACK);
 }
 void Enemy::draw_shw(N5110 &lcd,Gamepad &pad)
 {
-    if(_shno == 1) {
-        draw_shw1(lcd,pad);
-    }
-    if(_shno == 2) {
-        draw_shw1(lcd,pad);
-        draw_shw2(lcd,pad);
-    }
-    if(_shno == 3) {
-        draw_shw1(lcd,pad);
-        draw_shw2(lcd,pad);
-        draw_shw3(lcd,pad);
+    switch (_shno) {
+        case 1:
+            draw_shw1(lcd,pad);
+            break;
+        case 2:
+            draw_shw1(lcd,pad);
+            draw_shw2(lcd,pad);
+            break;
+        case 3:
+            draw_shw1(lcd,pad);
+            draw_shw2(lcd,pad);
+            draw_shw3(lcd,pad);
+            break;
     }
 }
 void Enemy::update_shw()
 {
-    _shwx1 =  _shwx1 + _vshw1.x;
-    _shwy1 =  _shwy1 + _vshw1.y;
-    _shwx2 =  _shwx2 + _vshw2.x;
-    _shwy2 =  _shwy2 + _vshw2.y;
-    _shwx3 =  _shwx3 + _vshw3.x;
-    _shwy3 =  _shwy3 + _vshw3.y;
+    _shooterWPos[0].x =  _shooterWPos[0].x + _shooterWSpeed[0].x;
+    _shooterWPos[0].y =  _shooterWPos[0].y + _shooterWSpeed[0].y;
+    _shooterWPos[1].x =  _shooterWPos[1].x + _shooterWSpeed[1].x;
+    _shooterWPos[1].y =  _shooterWPos[1].y + _shooterWSpeed[1].y;
+    _shooterWPos[2].x =  _shooterWPos[2].x + _shooterWSpeed[2].x;
+    _shooterWPos[2].y =  _shooterWPos[2].y + _shooterWSpeed[2].y;
 }
 
 Vector2D Enemy::get_shwpos(int shno)
 {
     if(shno == 1) {
-        Vector2D pos = {_shwx1,_shwy1};
+        Vector2D pos = {_shooterWPos[0].x,_shooterWPos[0].y};
         return pos;
     }
     if(shno == 2) {
-        Vector2D pos = {_shwx2,_shwy2};
+        Vector2D pos = {_shooterWPos[1].x,_shooterWPos[1].y};
         return pos;
     }
     if(shno == 3) {
-        Vector2D pos = {_shwx3,_shwy3};
+        Vector2D pos = {_shooterWPos[2].x,_shooterWPos[2].y};
         return pos;
     }
 }
-/*
-void Weapons::set_pos(int xpos, int ypos)
-{
-    _x = xpos;
-    _y = ypos;
-}*/
-void Enemy::reset_seeker(int seekno)
+
+void Enemy::reset_seeker(int seno)
 {
-    if(seekno == 1) {
-        _seeker1_xpos = rand_no(68);
-        _seeker1_ypos = 0;
-    }
-    if(seekno == 2) {
-        _seeker2_xpos = rand_no(68);
-        _seeker2_ypos = 0;
+    switch (seno) {
+        case 1:
+            _seekerPos[0].x = rand_no(68);
+            _seekerPos[0].y = 0;
+            break;
+        case 2:
+            _seekerPos[1].x = rand_no(68);
+            _seekerPos[1].y = 0;
+            break;
+        case 3:
+            _seekerPos[2].x = rand_no(68);
+            _seekerPos[2].y = 0;
+            break;
     }
-    if(seekno == 3) {
-        _seeker3_xpos = rand_no(68);
-        _seeker3_ypos = 0;
-    }
+
 }
-void Enemy::reset_shooter(int shooter)
+void Enemy::reset_shooter(int shno)
 {
-    if(shooter == 1) {
-        _shooter_xpos1 = rand_no(68);
-        _shooter_ypos1 = 5;
-    }
-    if(shooter == 2) {
-        _shooter_xpos2 = rand_no(68);
-        _shooter_ypos2 = 5;
-    }
-    if(shooter == 3) {
-        _shooter_xpos3 = rand_no(68);
-        _shooter_ypos3 = 5;
+    switch (shno) {
+        case 1:
+            _shooterPos[0].x = rand_no(68);
+            _shooterPos[0].y = 5;
+            break;
+        case 2:
+            _shooterPos[1].x = rand_no(68);
+            _shooterPos[1].y = 5;
+            break;
+        case 3:
+            _shooterPos[2].x = rand_no(68);
+            _shooterPos[2].y = 5;
+            break;
     }
 }
 Vector2D Enemy::get_seekerpos(int seekno)
 {
     if(seekno == 1) {
-        Vector2D seeker_pos = {_seeker1_xpos,_seeker1_ypos};
+        Vector2D seeker_pos = { _seekerPos[0].x, _seekerPos[0].y};
         return seeker_pos;
     }
     if(seekno == 2) {
-        Vector2D seeker_pos = {_seeker2_xpos,_seeker2_ypos};
+        Vector2D seeker_pos = { _seekerPos[1].x, _seekerPos[1].y};
         return seeker_pos;
     }
     if(seekno == 3) {
-        Vector2D seeker_pos = {_seeker3_xpos,_seeker3_ypos};
+        Vector2D seeker_pos = { _seekerPos[2].x, _seekerPos[2].y};
         return seeker_pos;
     }
 }
 Vector2D Enemy::get_shooterpos(int shno)
 {
     if(shno == 1) {
-        Vector2D shooter_pos = {_shooter_xpos1,_shooter_ypos1};
+        Vector2D shooter_pos = {_shooterPos[0].x,_shooterPos[0].y};
         return shooter_pos;
     }
     if(shno == 2) {
-        Vector2D shooter_pos = {_shooter_xpos2,_shooter_ypos2};
+        Vector2D shooter_pos = {_shooterPos[1].x,_shooterPos[1].y};
         return shooter_pos;
     }
     if(shno == 3) {
-        Vector2D shooter_pos = {_shooter_xpos3,_shooter_ypos3};
+        Vector2D shooter_pos = {_shooterPos[2].x,_shooterPos[2].y};
         return shooter_pos;
     }
 }
@@ -407,26 +412,26 @@
     int vmax = 3;
     int time = floor(time_elapsed);
     if(time%10 == 0) {
-        if(_vx1 > -vmax && _vx1 < vmax) {
-            _vx1 = _vx1 * 1.1;
+        if(_shooterSpeed[0].x > -vmax && _shooterSpeed[0].x < vmax) {
+            _shooterSpeed[0].x = _shooterSpeed[0].x * 1.1;
         }
-        if(_vx2 > - vmax && _vx2 < vmax) {
-            _vx2 = _vx2 * 1.1;
+        if(_shooterSpeed[1].x > - vmax && _shooterSpeed[1].x < vmax) {
+            _shooterSpeed[1].x = _shooterSpeed[1].x * 1.1;
         }
-        if(_vx3 > -vmax && _vx3 < vmax) {
-            _vx3 = _vx3 * 1.1;
+        if(_shooterSpeed[2].x > -vmax && _shooterSpeed[2].x < vmax) {
+            _shooterSpeed[2].x = _shooterSpeed[2].x * 1.1;
         }
-        if(_vy1 > -vmax && _vy1 < vmax) {
-            _vy1 = _vy1 * 1.1;
+        if(_shooterSpeed[0].y > -vmax && _shooterSpeed[0].y < vmax) {
+            _shooterSpeed[0].y = _shooterSpeed[0].y * 1.1;
         }
-        if(_vy2 > -vmax && _vy2 < vmax) {
-            _vy2 = _vy2 * 1.1;
+        if(_shooterSpeed[1].y > -vmax && _shooterSpeed[1].y < vmax) {
+            _shooterSpeed[1].y = _shooterSpeed[1].y * 1.1;
         }
-        if(_vy3 > -vmax && _vy3 < vmax) {
-            _vy3 = _vy3 * 1.1;
+        if(_shooterSpeed[2].y > -vmax && _shooterSpeed[2].y < vmax) {
+            _shooterSpeed[2].y = _shooterSpeed[2].y * 1.1;
         }
     }
-    // printf("time = %d, _vx1 = %f\n",time,_vx1);
+    // printf("time = %d, _shooterSpeed[0].x = %f\n",time,_shooterSpeed[0].x);
 }
 int Enemy::closest(int x1, int y1, int x2, int y2)
 {
@@ -439,19 +444,13 @@
 Vector2D Enemy::find_closest(int ship_xpos,int ship_ypos, int seno, int shno)
 {
     // get the distance for all enemies
-    int sh1 = closest(ship_xpos,ship_ypos,_shooter_xpos1,_shooter_ypos1);
-    int sh2 = closest(ship_xpos,ship_ypos,_shooter_xpos2,_shooter_ypos2);
-    int sh3 = closest(ship_xpos,ship_ypos,_shooter_xpos3,_shooter_ypos3);
-    int se1 = closest(ship_xpos,ship_ypos,_seeker1_xpos,_seeker1_ypos);
-    int se2 = closest(ship_xpos,ship_ypos,_seeker2_xpos,_seeker2_ypos);
-    int se3 = closest(ship_xpos,ship_ypos,_seeker3_xpos,_seeker3_ypos);
-    printf("sh1 = %d\n",sh1);
-    printf("sh2 = %d\n",sh2);
-    printf("sh3 = %d\n",sh3);
-    printf("se1 = %d\n",se1);
-    printf("se2 = %d\n",se2);
-    printf("se3 = %d\n",se3);
-    
+    int sh1 = closest(ship_xpos,ship_ypos,_shooterPos[0].x,_shooterPos[0].y);
+    int sh2 = closest(ship_xpos,ship_ypos,_shooterPos[1].x,_shooterPos[1].y);
+    int sh3 = closest(ship_xpos,ship_ypos,_shooterPos[2].x,_shooterPos[2].y);
+    int se1 = closest(ship_xpos,ship_ypos, _seekerPos[0].x, _seekerPos[0].y);
+    int se2 = closest(ship_xpos,ship_ypos, _seekerPos[1].x, _seekerPos[1].y);
+    int se3 = closest(ship_xpos,ship_ypos, _seekerPos[2].x, _seekerPos[2].y);
+   
     int close[6] = {sh1,sh2,sh3,se1,se2,se3};
     // find index of the smallest element
     int index;
@@ -462,31 +461,24 @@
          index = i;
       }
     }
-    printf("index = %d, _shno = %d, _seno = %d\n",index,shno,seno);
     // return the position of the closest enemy
     if(index == 0 && shno >= 1){
-       printf("shooter1\n"); 
-       return {_shooter_xpos1,_shooter_ypos1};
+       return {_shooterPos[0].x,_shooterPos[0].y};
     }
     if(index == 1 && shno >= 2){
-       // printf("shooter_xpos2 = %d, shooter_ypos2 = %d\n",_shooter_xpos2,_shooter_ypos2); 
-       return {_shooter_xpos2,_shooter_ypos2}; 
+       return {_shooterPos[1].x,_shooterPos[1].y}; 
     }
     if(index == 2 && shno >= 3){
-       printf("shooter3\n");
-       return {_shooter_xpos3,_shooter_ypos3}; 
+       return {_shooterPos[2].x,_shooterPos[2].y}; 
     }
     if(index == 3 && seno >= 1 ){
-       printf("seeker1\n"); 
-       return {_seeker1_xpos,_seeker1_ypos}; 
+       return { _seekerPos[0].x, _seekerPos[0].y}; 
     }
     if(index == 4 && seno >= 2){
-       printf("seeker2\n"); 
-       return {_seeker2_xpos,_seeker2_ypos}; 
+       return { _seekerPos[1].x, _seekerPos[1].y}; 
     }
     if(index == 5 && seno >= 3){
-       printf("seeker3\n");
-       return {_seeker3_xpos,_seeker3_ypos};  
+       return { _seekerPos[2].x, _seekerPos[2].y};  
     }
     
 } 
\ No newline at end of file