ELEC2645 (2018/19) / Mbed 2 deprecated el17aio

Dependencies:   mbed

Revision:
37:8d8c8cce0bc7
Parent:
36:c25417f0d150
Child:
38:4571537238ed
--- a/RosenEngine/RosenEngine.cpp	Fri May 03 18:56:06 2019 +0000
+++ b/RosenEngine/RosenEngine.cpp	Sat May 04 05:37:33 2019 +0000
@@ -18,7 +18,7 @@
     // initialise the game parameters
     _ship.init(ship_width,ship_height,ship_speed,ship_xpos,ship_ypos);
     // place seeker above the ship
-    _enemy.init(48,0,3);
+    _enemy.init(3);
     _menu.init(16);
     _health.init(_shipno);
 
@@ -92,6 +92,7 @@
     kestrelw_shooter_collision(pad);
     imperionw_shooter_collision(pad);
     check_health();
+    rand_no();
 }
 void RosenEngine::get_pos()
 {
@@ -99,9 +100,9 @@
     ship_xpos = ship_pos.x;
     ship_ypos = ship_pos.y;
 
-    _shooter1_pos = _enemy.get_shooter1pos();
-    _shooter2_pos = _enemy.get_shooter2pos();
-    _shooter3_pos = _enemy.get_shooter3pos();
+    _shooter1_pos = _enemy.get_shooterpos(1);
+    _shooter2_pos = _enemy.get_shooterpos(2);
+    _shooter3_pos = _enemy.get_shooterpos(3);
 
     _weapons.init(ship_xpos, ship_ypos, ship_width);
     _ycursor = _menu.get_ycursor();
@@ -252,9 +253,9 @@
 }
 void RosenEngine::shooterw_ship_collision(Gamepad &pad)
 {
-    Vector2D _shooterw1_pos = _enemy.get_sh1wpos();
-    Vector2D _shooterw2_pos = _enemy.get_sh2wpos();
-    Vector2D _shooterw3_pos = _enemy.get_sh3wpos();
+    Vector2D _shooterw1_pos = _enemy.get_shwpos(1);
+    Vector2D _shooterw2_pos = _enemy.get_shwpos(2);
+    Vector2D _shooterw3_pos = _enemy.get_shwpos(3);
 
     bool collision1;
     bool collision2;
@@ -391,4 +392,11 @@
         printf("player deaad\n");
         _dead = true;
     } 
+}
+int RosenEngine::rand_no()
+{
+    srand(time(NULL));
+    int rand_no = (rand() %45) + 1;
+    printf("random no = %d\n",rand_no);
+    return rand_no;
 }
\ No newline at end of file