ELEC2645 (2018/19) / Mbed 2 deprecated fy14lkaa

Dependencies:   mbed

Revision:
148:83e5a4dedffd
Parent:
147:c008c0a32d23
Child:
149:bd0f37008f5a
--- a/SpaceEngine/SpaceEngine.cpp	Thu May 09 11:57:29 2019 +0000
+++ b/SpaceEngine/SpaceEngine.cpp	Thu May 09 12:09:59 2019 +0000
@@ -3,7 +3,7 @@
 SpaceEngine::SpaceEngine() //constructor of class SpaceEngine
 {
 }
-SpaceEngine::~SpaceEngine() ////Destructor of class SpaceEngine
+SpaceEngine::~SpaceEngine() //Destructor of class SpaceEngine
 {
 }
 
@@ -15,7 +15,7 @@
     _x_spaceship=x_spaceship; //represents the x-cooridante of the spaceship.
     _y_spaceship=y_spaceship; //represents the y-cooridante of the spaceship.
     _speed_spaceship=speed_spaceship; // speed of the spaceship.
-    _x_bullet=x_bullet; //represents the x-cooridante of the spaceship. 
+    _x_bullet=x_bullet; //represents the x-cooridante of the spaceship.
     _y_bullet=y_bullet; //represents the y-cooridante of the spaceship.
     _fired_bullet= fired_bullet;  // spaceship fired the alien by relaseing the bullet.
     _x_alien= x_alien;  //represents the x-cooridante of the alien.
@@ -29,18 +29,18 @@
     _alien_killed = 0;  // set the killed alien at 0.
 }
 
-// void function for Gamepad library to read the position of the objects. 
+// void function for Gamepad library to read the position of the objects.
 void SpaceEngine::read_input(Gamepad &pad)
 {
 
     _d = pad.get_direction();
     _mag = pad.get_mag();
 }
-/**this function draw the objects on the screen 
+/**this function draw the objects on the screen
 *by using the (N5110 &lcd) libraries
 * if statment to check if the alien is alive so the lcd can draw it on the screen
-* else if statment will check if the alien dead so it should disappear 
-*also it draws the spaceship 
+* else if statment will check if the alien dead so it should disappear
+*also it draws the spaceship
 */
 
 void  SpaceEngine::draw(N5110 &lcd)
@@ -63,9 +63,9 @@
 
 }
 
-/* 
+/*
 *this void function for reading the the positions of the inputs(objects)by(Gamepad &pad)libraries in class SpaceEngine to detect the collisions.
-*this inculde if statment that shows when joystic's direction to the east the bullt will fired.
+*this inculde if statment that shows when joystic's direction to the east the bullt will be fired.
 */
 void SpaceEngine::update(Gamepad &pad)
 {
@@ -78,26 +78,26 @@
     _y_bullet = _bullet.get_pos_y();
     _x_bullet = _bullet.get_pos_x();
     if(_d==E) {
-        _fired_bullet=1;
-        
- _bullet.set_pos(_spaceship.get_pos_x()+33, _spaceship.get_pos_y());
- }
+        _fired_bullet=1;  
+       // printf("bullet fired alien\n")
+        _bullet.set_pos(_spaceship.get_pos_x()+33, _spaceship.get_pos_y());
+    }
+}
+
+/*void function that checks the collision between the objects
+*if statment is to detect if x-coordinate of the bullet is larger or equal 65
+*and less than or equal to the 68 and if y-cooridante of the bullet is larger
+*than y-corrdindate of the alien-5 and y_alien+15 is larger or equal y_bullet
+*then the alien gets killed.
+*/
+
+void SpaceEngine::check_space_collision(Gamepad &pad)
+{
+
+    if(_x_bullet >= 65 && _x_bullet <= 68 && _y_bullet >= _y_alien-5 && _y_bullet <= _y_alien+15) {
+        _alien.setAlive(false);
+         // printf("alive alien false\n")
+        _alien_killed++;
     }
 
-
-   
- /*void function that checks the collision between the objects 
- *if statment is to detect if x-coordinate of the bullet is larger or equal 65 
- *and less than or equal to the 68 and if y-cooridante of the bullet is larger 
- *than y-corrdindate of the alien-5 and y_alien+15 is larger or equal y_bullet
- *then the alien gets killed. 
- */
-
-void SpaceEngine::check_space_collision(Gamepad &pad) {
-
-        if(_x_bullet >= 65 && _x_bullet <= 68 && _y_bullet >= _y_alien-5 && _y_bullet <= _y_alien+15) {
-            _alien.setAlive(false);
-            _alien_killed++;
-        }
-
-    }
\ No newline at end of file
+}
\ No newline at end of file