Dependencies:   mbed

Revision:
27:eb755a345b1f
Parent:
18:828e9f6ddfdb
Child:
43:1ac200335a68
--- a/AlienBullet/AlienBullet.cpp	Fri May 15 15:49:43 2020 +0000
+++ b/AlienBullet/AlienBullet.cpp	Sat May 16 16:18:32 2020 +0000
@@ -3,40 +3,45 @@
 AlienBullet::AlienBullet()
 {
 }
+
 AlienBullet::~AlienBullet()
 {
 }
 
-void AlienBullet::init(int x, int y)  {
-    Speed = 1;
-    Hit = false;
-    X = x;                                      //x=Middle of the ship
-    Y = y;    
-                                      //y=Top of the ship Height is ship Height
+void AlienBullet::init(int x, int y)  
+{
+    _speed = 1;                                                                 //bullet speed set to 1
+    _hit = false;                                                               //bullet is alive and able to cause collision
+    _x = x;                                                                     //x position is set as input of function (middle of alien)
+    _y = y;                                                                     //y position is set as input of function (bottom of alien)
 }
 
 void AlienBullet::render(N5110 &lcd)
 {
-    if(Hit == false) {
-        lcd.setPixel(X,Y,true);
+    if(_hit == false) {
+        lcd.setPixel(_x,_y,true);                                               //draws a pixel black if bullet has not yet caused a hit
     }
 }
 
-void AlienBullet::update() {
-    Y+= Speed;
+void AlienBullet::update() 
+{
+    _y+= _speed;                                                                //y position increasing with speed (moving down screen)
 }
     
-Vector2D AlienBullet::get_position() {
-    Vector2D p = {X,Y};
+Vector2D AlienBullet::get_position() 
+{
+    Vector2D p = {_x,_y};                                                       //returns a 2D vector of the x and y position of the bullet
     return p;    
 }
 
-void AlienBullet::set_hit(bool x) {
-    Hit = x;
+void AlienBullet::set_hit(bool x) 
+{
+    _hit = x;                                                                   //sets the hit value of the bullet
 }
 
-bool AlienBullet::get_hit() {
-    bool x = Hit;
+bool AlienBullet::get_hit() 
+{
+    bool x = _hit;                                                              //returns the hit value of the bullet
     return x;
 }