Laila Al Badwawi 200906179 SpaceInvaders I declare this my own independent work and understand the university rules on plagiarism.

Dependencies:   mbed

Revision:
137:fe80c0f2da9d
Parent:
134:2da2db5871bd
Child:
139:c46a2cef7e09
--- a/Alien/Alien.cpp	Wed May 08 19:10:28 2019 +0000
+++ b/Alien/Alien.cpp	Thu May 09 04:45:37 2019 +0000
@@ -1,31 +1,34 @@
 #include "Alien.h"
 
 
-Alien::Alien()
+Alien::Alien()  //constructor of class Alien
 {
 
 }
 
-Alien::~Alien()
+Alien::~Alien() //Destructor of class Alien
 {
 
 }
 
+//intialise the prameters of class Alien 
+void Alien::init(int x_alien,int y_alien, int speed_alien)
+{
+
+    _x_alien = x_alien; // the position of alien at x-cooridante.
+    _y_alien = y_alien; //  the position of alien at y-cooridante.
+    _speed_alien = speed_alien; // the speed of the alien. 
+    _alive = true;             //intialise the alive alien.
+
+}
+
 
-void Alien::init(int x_alien,int y_alien, int speed_alien)
-{
-
-    _x_alien = x_alien;
-    _y_alien = y_alien;
-    _speed_alien = speed_alien;
-    _alive = true;
-
-}
-
+// void function to draw the alien by using N5110 library 
 void Alien::draw(N5110 &lcd)
 {
+    //drawing the alien by using lcd.drawSprite.
 
-    lcd.drawSprite(_x_alien,_y_alien,32,32,(int *)alien2);
+    lcd.drawSprite(_x_alien,_y_alien,32,32,(int *)alien2); 
 }
 
 
@@ -33,15 +36,18 @@
 void  Alien::update(Direction d,float mag)
 {
     _speed_alien = int(mag*10.0f);
-}
+
 
-srand(time(NULL));
+  srand(time(NULL));   // lets the alien move randomly.
 _y_alien += rand() % 17 - 8;
 
 
-if(_y_alien>=30)
+
+if(_y_alien>=30)   //if statment to check the position of the alien at y_cooridante.
 {
     _y_alien=30;
+    
+    //printif("alien at y_cooridante equal 30\n")
 } else if(_y_alien<=0)
 {
     _y_alien=0;
@@ -51,40 +57,50 @@
 
 
 
-int  Alien::get_pos_x()
+int  Alien::get_pos_x() // to get the position of the alien at x_cooridante.
 {
-    return _x_alien;
+    return _x_alien;   //x_corridante of the alien.
 }
 
-int Alien::get_pos_y()
+int Alien::get_pos_y() //function to get the position of the alien at y_cooridante.
 {
     return _y_alien;
 }
 
+
+//void function to set the position of the alien in x-cooridante and y_cooridante.
 void Alien::set_pos(int x, int y)
 {
-    _x_alien = x;
+    _x_alien = x;   
     _y_alien = y;
 }
 
 void Alien::add_score()
 
 {
-    _score++;
+    _score++;     // increment the scores by 1.
+    //printf("scores increament by 1\n")
 }
-int Alien::get_score()
-{
-    return _score;
+int Alien::get_score()  
+{              
+    return _score;    //return the numbers of the scores which achived by the alien.
+    //printf("returned scores\n")
 }
 
+
+
 bool Alien::isAlive()
 {
-    return _alive;
+    return _alive;    //return the alive alien in bool.
+    
+    //printf("alive alien is true\n")
 }
 
-void Alien::setAlive(bool alive)
+
+void Alien::setAlive(bool alive)  //void function to set up the alive alien.
 {
     _alive = alive;
+     //printf("alive alien is set up\n")
 }