ELEC2645 (2018/19) / Mbed 2 deprecated fy14lkaa

Dependencies:   mbed

Revision:
125:b83378770171
Parent:
124:77f379153715
Child:
126:c63c5ad39f73
--- a/SpaceEngine/SpaceEngine.cpp	Sun May 05 15:21:40 2019 +0000
+++ b/SpaceEngine/SpaceEngine.cpp	Sun May 05 15:24:38 2019 +0000
@@ -59,85 +59,19 @@
 
 
 }
-/*void SpaceInvadersEngine::check_Alien_collision(Gamepad &pad)
-{
-
-    // read current bullet attributes
-    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
-    if (bullet_pos.y <= 1) {  //  1 due to 1 pixel boundary
-        bullet_pos.y = 1;  // bounce off ceiling without going off screen
-        bullet_velocity.y = -bullet_velocity.y;
-        // audio feedback
-        pad.tone(750.0,0.1);
-    }
-
-    // check if the bullet hits bottom of the Alien
-    else if (bullet_pos.y + bullet1_size >= (HEIGHT-1) ) { // bottom pixel is 47
-        // hit bottom
-        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
-    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();
-
-
-    / check p1 first
-    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_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_ship1_width;
-        bullet_velocity.x = -bullet_velocity.x;
-        // audio feedback
-        pad.tone(1000.0,0.1);
-    }
-
-}
-*/
-/*void SpaceInvadersEngin::check_goal(Gamepad &pad)
+void SpaceEngine::update(Gamepad &pad)
 {
-    Vector2D bullet_pos = bullet1.get_pos();
-    // spaceship has scored
-    if (bullet_pos.x + bullet1_size < 0) {
-        _sace_ship.add_score();
-        bullet1.init(bullet1_size,_speed);
-        pad.tone(1500.0,0.5);
-        pad.leds_on();
-        wait(0.5);
-        pad.leds_off();
-    }
+    _bullet.update(_d,_mag);
+    _alien.update(_d,_mag);
+    _spaceship.update(_d,_mag);
+    if(_d==E){
+        _fired_bullet=1;
+            //_x_bullet=11;
+            //_y_bullet=y;
+            _bullet.set_pos(_spaceship.get_pos_x()+11, _spaceship.get_pos_y());
+        }
+    
+    
+}
 
-    void SpaceInvadersEngin::print_scores(N5110 &lcd) {
-        // get scores from the spaceship
-        int space_ship_score = space_ship1.get_score();
-
-
-        // print to LCD i
-        char buffer1[14];
-        sprintf(buffer1,"%2d",space_ship_score);
-        lcd.printString(buffer1,WIDTH/2 - 20,1);  // font is 8 wide, so leave 4 pixel gape from middle assuming two digits
-
-    }
-
-*/