Ikenna Adrian Ozoemena 201157039

Dependencies:   mbed

Revision:
37:8d8c8cce0bc7
Parent:
35:3341f2bd0408
Child:
38:4571537238ed
--- a/Enemy/Enemy.cpp	Fri May 03 18:56:06 2019 +0000
+++ b/Enemy/Enemy.cpp	Sat May 04 05:37:33 2019 +0000
@@ -30,36 +30,36 @@
     {0,0,0,0,1,0,1,0,0,0,0},
     {0,0,0,0,0,1,0,0,0,0,0},
 };
-void Enemy::init(int seeker_xpos,int seeker_ypos,int shno)
+void Enemy::init(int shno)
 {
     // initialize seeker
-    _seeker_xpos = seeker_xpos;
-    _seeker_ypos = seeker_ypos;
+    _seeker_xpos = rand_no(68);
+    _seeker_ypos = 0;
     _shno = shno;
     // initialize shooter
     _vx1 = 1;
-    _vx2 = 1;
-    _vx3 = 1;
+    _vx2 = 2;
+    _vx3 = 3;
     _vy1 = 1;
-    _vy2 = 1;
+    _vy2 = 2;
     _vy3 = 1;
     // for now just starting them spaced apart add randomizer later
     if(_shno == 1) {
-        _shooter_xpos1 = 1;
+        _shooter_xpos1 = rand_no(68);
         _shooter_ypos1 = 1;
     }
     if(_shno == 2) {
-        _shooter_xpos1 = 1;
+        _shooter_xpos1 = rand_no(68);
         _shooter_ypos1 = 1;
-        _shooter_xpos2 = 30;
+        _shooter_xpos2 = rand_no(68);
         _shooter_ypos2 = 1;
     }
     if(_shno == 3) {
-        _shooter_xpos1 = 1;
+        _shooter_xpos1 = rand_no(68);
         _shooter_ypos1 = 1;
-        _shooter_xpos2 = 30;
+        _shooter_xpos2 = rand_no(68);
         _shooter_ypos2 = 1;
-        _shooter_xpos3 = 60;
+        _shooter_xpos3 = rand_no(68);
         _shooter_ypos3 = 1;
     }
 
@@ -279,20 +279,20 @@
      _shwy3 =  _shwy3 + _vshw3.y;
 }
 
-Vector2D Enemy::get_sh1wpos()
+Vector2D Enemy::get_shwpos(int shno)
 {
+    if(shno == 1){
     Vector2D pos = {_shwx1,_shwy1};
     return pos;
-}
-Vector2D Enemy::get_sh2wpos()
-{
+    }
+    if(shno == 2){
     Vector2D pos = {_shwx2,_shwy2};
-    return pos;
-}
-Vector2D Enemy::get_sh3wpos()
-{
+    return pos;   
+    }
+    if(shno == 3){
     Vector2D pos = {_shwx3,_shwy3};
-    return pos;
+    return pos;   
+    }
 }
 /*
 void Weapons::set_pos(int xpos, int ypos)
@@ -302,21 +302,21 @@
 }*/
 void Enemy::reset_seeker()
 {
-    _seeker_xpos = 0;
+    _seeker_xpos = rand_no(68);
     _seeker_ypos = 0;
 }
 void Enemy::reset_shooter(int shooter)
 {
     if(shooter == 1){
-    _shooter_xpos1 = 5;
+    _shooter_xpos1 = rand_no(68);
     _shooter_ypos1 = 5;
     }
     if(shooter == 2){
-    _shooter_xpos2 = 10;
+    _shooter_xpos2 = rand_no(68);
     _shooter_ypos2 = 5;
     }
     if(shooter == 3){
-    _shooter_xpos3 = 15;
+    _shooter_xpos3 = rand_no(68);
     _shooter_ypos3 = 5;
     }
 }
@@ -325,18 +325,25 @@
     Vector2D seeker_pos = {_seeker_xpos,_seeker_ypos};
     return seeker_pos;
 }
-Vector2D Enemy::get_shooter1pos()
+Vector2D Enemy::get_shooterpos(int shno)
 {
+    if(shno == 1){
     Vector2D shooter_pos = {_shooter_xpos1,_shooter_ypos1};
     return shooter_pos;
-}
-Vector2D Enemy::get_shooter2pos()
-{
+    }
+    if(shno == 2){
     Vector2D shooter_pos = {_shooter_xpos2,_shooter_ypos2};
-    return shooter_pos;
+    return shooter_pos;    
+    }
+    if(shno == 3){
+    Vector2D shooter_pos = {_shooter_xpos3,_shooter_ypos3};
+    return shooter_pos;   
+    }
 }
-Vector2D Enemy::get_shooter3pos()
+int Enemy::rand_no(int scale)
 {
-    Vector2D shooter_pos = {_shooter_xpos3,_shooter_ypos3};
-    return shooter_pos;
+    srand(time(NULL));
+    int rand_no = (rand() %scale) + 1;
+    // printf("random no = %d\n",rand_no);
+    return rand_no;
 }
\ No newline at end of file