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

Dependencies:   mbed

Revision:
149:bd0f37008f5a
Parent:
142:92f277a3e7e6
--- a/Alien/Alien.cpp	Thu May 09 12:09:59 2019 +0000
+++ b/Alien/Alien.cpp	Thu May 09 14:13:43 2019 +0000
@@ -1,6 +1,6 @@
 #include "Alien.h"
 
-
+//nothing to be done here.
 Alien::Alien()  //constructor of class Alien
 {
 
@@ -11,98 +11,84 @@
 
 }
 
-
+//intialise the prameters of class Alien
 void Alien::init(int x_alien,int y_alien, int speed_alien)
 {
-   //intialise the prameters of class Alien 
-    _x_alien = x_alien; // the position of alien at x-cooridante.
+    _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. 
+    _speed_alien = speed_alien; // the speed of the alien.
     _alive = true;             //intialise the alive alien.
 
 }
 
-
-// void function to draw the alien by using N5110 library 
+// 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);
 }
 
-
-
 void  Alien::update(Direction d,float mag)
 {
     _speed_alien = int(mag*10.0f);
 
-
-  srand(time(NULL));   // lets the alien move randomly.
-_y_alien += rand() % 17 - 8;
-
-
-
-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;
+    srand(time(NULL));   // lets the alien move randomly.
+    _y_alien += rand() % 17 - 8;  // random movment
+    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;
+        //printif("alien at y_cooridante equal 0\n")
+    }
 }
 
-}
-
-
-
-int  Alien::get_pos_x() // to get the position of the alien at x_cooridante .
+// to get the position of the alien at x_cooridante .
+int  Alien::get_pos_x()
 {
     return _x_alien;   // retutn x_corridante of the alien in integer.
 }
 
-int Alien::get_pos_y() //function to get the position of the alien at y_cooridante.
+//function to get the position of the alien at y_cooridante.
+int Alien::get_pos_y()
 {
     return _y_alien; // retutn y_corridante of the alien in integer.
 }
 
-
 //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;    //the position of the alien at x-coordniate is equal to x. 
-    _y_alien = y;    //the position of the alien at y-coordniate is equal to y. 
+    _x_alien = x;    //the position of the alien at x-coordniate is equal to x.
+    _y_alien = y;    //the position of the alien at y-coordniate is equal to y.
 }
 
 //void function to add the scores of the alien.
 void Alien::add_score()
-
 {
     _score++;     // increment the scores by 1.
     //printf("scores increament by 1\n")
 }
 
 //void function to get the scores of the alien.
-int Alien::get_score()  
-{              
+int Alien::get_score()
+{
     return _score;    //return the numbers of the scores which achived by the alien.
     //printf("returned scores\n")
 }
 
-
-
+// this bool function to check if the alive alien
 bool Alien::isAlive()
 {
-    return _alive;    //return the alive alien in bool.
-    
-    //printf("alive alien is true\n")
+//return the alive alien in bool.
+    return _alive;
+//printf("alive alien is true\n")
 }
+
 //void function to set up the alive alien.
-
-void Alien::setAlive(bool alive){  
+void Alien::setAlive(bool alive)
+{
     _alive = alive;
-     //printf("alive alien is set up\n")
+    //printf("alive alien is set up\n")
 }