Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Gamepad N5110 mbed-rtos
Diff: Spacecraft/Spacecraft.cpp
- Revision:
- 5:016a7315b75d
- Parent:
- 2:b5c1bb7a39de
diff -r 4d673fb2d9dc -r 016a7315b75d Spacecraft/Spacecraft.cpp
--- a/Spacecraft/Spacecraft.cpp	Sun May 05 17:41:46 2019 +0000
+++ b/Spacecraft/Spacecraft.cpp	Mon May 06 18:29:49 2019 +0000
@@ -11,7 +11,7 @@
 
 }
 
-    
+// sprite of the player spacecraft 
 int H_spacecraft [11][11] = {
     
     { 0,0,1,0,0,1,0,0,0,0,0 },
@@ -29,7 +29,7 @@
     
 };     
 
-void Spacecraft::init(int x,int y)
+void Spacecraft::init(int x,int y) // initialise the x and y position
 {
     _x = x;  // default x position
     _y = y;  // default y position
@@ -49,8 +49,9 @@
 {
     _speed = int(mag*5.0f);  // scale is arbitrary, could be changed in future
 
-    // update y value depending on direction of movement
+    // update x and y value depending on the direction of the movement
     // North is decrement as origin is at the top-left so decreasing moves up
+    // East is increment and West is decrement
     if (d == N) {
         _y-=_speed;
     } else if (d == S) {
@@ -87,7 +88,7 @@
     }
 }
 
-void Spacecraft::update_move()
+void Spacecraft::update_move() // moves south when the spacecraft dies
 {
     _increment = 5.0;
     
@@ -96,14 +97,16 @@
     
 void Spacecraft::add_health()
 {
-    _health++;
+    _health++; // Adds health
 }
 int Spacecraft::get_health()
 {
-    return _health;
+    return _health; // Gets the value of health
 }
 
-Vector2D Spacecraft::get_pos() {
+Vector2D Spacecraft::get_pos() 
+{
+    // Gets the position of the spacecraft
     Vector2D p = {_x,_y};
     return p;    
 }