ELEC2645 (2018/19) / Mbed 2 deprecated fy14lkaa

Dependencies:   mbed

Revision:
92:8a1b14488ca5
Parent:
91:f9e2ff484014
--- a/SpaceInvadersEngine/SpaceInvadersEngine.cpp	Sun Apr 28 19:44:34 2019 +0000
+++ b/SpaceInvadersEngine/SpaceInvadersEngine.cpp	Sun May 05 01:27:55 2019 +0000
@@ -11,8 +11,9 @@
 
 }
 
-
-
+Alien alien;
+bullet bullet1;
+space_ship  space_ship1;
 
 void SpaceInvadersEngine::init(int space_ship_width,int space_ship_height,int bullet_size, int Alien_size, int speed)
 {
@@ -40,30 +41,30 @@
 
     //score
     print_scores(lcd);
-    Alien.draw(lcd);
-    _space_ship.draw(lcd);
-    _bullet.draw(lcd);
+    alien.draw(lcd);
+    space_ship1.draw(lcd);
+    bullet1.draw(lcd);
 }
 
 void  SpaceInvadersEngine::update(Gamepad &pad)
 {
     check_goal(pad);
-    _bullet.update();
-    _space_ship.update(_d,_mag);
+    bullet1.update();
+    space_ship1.update(_d,_mag);
 
-    _A1ien.update(_d,_mag);
+    alien.update();
 
     check_Alien_collision(pad);
-    check_space_ship_collisions(pad);
+    checkspace_ship_collisions(pad);
 
 
 }
-void SpaceInvadersEngine::check_Alien_collision(Gamepad &pad)
+/*void SpaceInvadersEngine::check_Alien_collision(Gamepad &pad)
 {
 
     // read current bullet attributes
-    Vector2D bullet_pos = _bullet.get_pos();
-    Vector2D bullet_velocity = _bullet.get_velocity();
+    Vector2D bullet_pos = bullet.get_pos();
+    Vector2D bullet_velocity = bullet1.get_velocity();
     //check if the bullet hit the top of the alien
 
     // check if the bullet hits top of the Alien
@@ -75,51 +76,52 @@
     }
 
     // check if the bullet hits bottom of the Alien
-    else if (bullet_pos.y + _bullet_size >= (HEIGHT-1) ) { // bottom pixel is 47
+    else if (bullet_pos.y + bullet1_size >= (HEIGHT-1) ) { // bottom pixel is 47
         // hit bottom
-        bullet_pos.y = (HEIGHT-1) - _bullet_size;  // stops bullet going off screen
+        bullet_pos.y = (HEIGHT-1) - bullet1_size;  // stops bullet going off screen
         bullet_velocity.y = -bullet_velocity.y;
         // audio feedback
         pad.tone(750.0,0.1);
     }
 
     // update bullet parameters
-    _bullet.set_velocity(bullet_velocity);
-    _bullet.set_pos(bullet_pos);
+    bullet1.set_velocity(bullet_velocity);
+    bullet1.set_pos(bullet_pos);
 }
+*/
+/*void SpaceInvadersEngine::checkspace_ship_collisions(Gamepad &pad)
+{
+    // read current bullet attributes
+    Vector2D bullet_pos = bullet1.get_pos();
+    Vector2D bullet_velocity = bullet1.get_velocity();
 
-void SpaceInvadersEngine::check_space_ship_collisions(Gamepad &pad){
-     // read current bullet attributes
-    Vector2D bullet_pos = _bullet.get_pos();
-    Vector2D bullet_velocity = _bullet.get_velocity();
-    
-    
+
     / check p1 first
-    Vector2D p1_pos = _space_ship.get_pos();
+    Vector2D p1_pos = space_ship1.get_pos();
 
     // see if bullet has hit the paddle by checking for overlaps
     if (
         (bullet_pos.y >= space_ship.y) && //top
         (bullet_pos.y <= space_ship_pos.y + _paddle_height) && //bottom
-        (bullet_pos.x >= _space_shipx) && //left
-        (bullet_pos.x <= _space_shipx + _space_ship_width)  //right
+        (bullet_pos.x >= space_ship1x) && //left
+        (bullet_pos.x <= space_ship1x + space_ship1_width)  //right
     ) {
         // if it has, fix position and reflect x velocity
-        bullet_pos.x = _p1x + _space_ship_width;
+        bullet_pos.x = _p1x + space_ship1_width;
         bullet_velocity.x = -bullet_velocity.x;
         // audio feedback
         pad.tone(1000.0,0.1);
     }
 
 }
-
-void SpaceInvadersEngin::check_goal(Gamepad &pad)
+*/
+/*void SpaceInvadersEngin::check_goal(Gamepad &pad)
 {
-    Vector2D bullet_pos = _bullet.get_pos();
+    Vector2D bullet_pos = bullet1.get_pos();
     // spaceship has scored
-    if (bullet_pos.x + _bullet_size < 0) {
+    if (bullet_pos.x + bullet1_size < 0) {
         _sace_ship.add_score();
-        _bullet.init(_bullet_size,_speed);
+        bullet1.init(bullet1_size,_speed);
         pad.tone(1500.0,0.5);
         pad.leds_on();
         wait(0.5);
@@ -128,7 +130,7 @@
 
     void SpaceInvadersEngin::print_scores(N5110 &lcd) {
         // get scores from the spaceship
-        int space_ship_score = _space_ship.get_score();
+        int space_ship_score = space_ship1.get_score();
 
 
         // print to LCD i
@@ -138,4 +140,4 @@
 
     }
 
-
+*/