Matis Requis 201241242

Dependencies:   mbed

Tempest Game

Game Screen

https://os.mbed.com/media/uploads/MatisRequis/tempest_board_wiki.png The board is made of 12 columns. The Hero stays at the top of the column

Game Controls

https://os.mbed.com/media/uploads/MatisRequis/gamepad_buttons.png

To control the hero spaceship point the joystick to the column you want the hero to go to.

Press the A button to shoot a bullet in the column you are currently in.

Revision:
10:2ae9d4145410
Parent:
9:759b419fec3b
--- a/Alien/Alien.cpp	Tue May 26 07:26:13 2020 +0000
+++ b/Alien/Alien.cpp	Tue May 26 16:31:22 2020 +0000
@@ -8,18 +8,23 @@
     
 }
 
+//initialises the alien with all the speed values and the path it uses
 void Alien::init(int column, int speed) {
-    _currentpos = 14;
-    srand(time(NULL)); //makes pseudo rando number generator have different seed every time based on the current time
+    _currentpos = 13;
+    //makes pseudo rando number generator have different seed every time based on the current time
+    srand(time(NULL)); 
     _column = column;
     _board.path();
     _alienspeed = speed;
-    _movcount = 1;
+    _movcount = 10;
     
 }
 
+//draws the alien
 void Alien::draw(N5110 &lcd) {
     getxy();
+    
+    //draws the alien in differnet orientation depending on the column
     if (_column < 3 && _column >= 0) {
         lcd.drawLine(_x-1, _y, _x+1, _y, 1);
         lcd.drawLine(_x-2, _y+1, _x+2, _y+1, 1);
@@ -47,6 +52,7 @@
         _column += _rand;
         
         _currentpos--;
+        //resets the speed limiter
         _movcount = _alienspeed;
     } else {
         _movcount--;
@@ -54,27 +60,26 @@
         
 }
 
+//checks if the alien is at the end of the lane
 int Alien::checkdelete() {
-    if (_currentpos < 1) {
-        _loss = 1;  
+    if (_currentpos < 1) {  
         return 1;
     } else {
         return 0;
     }
 }
 
-int Alien::checkobjective() {
-    if (_loss) {
-        return 1;
-    } else { 
-    return 0; 
-    }
-}
-
+//returns the current position of the alien
 Vector2D Alien::getxy() {
     _x = _board.drawcolumn[_column][_currentpos].x;
     _y = _board.drawcolumn[_column][_currentpos].y;
-    
-    Vector2D p = {_board.drawcolumn[_column][_currentpos].x, _board.drawcolumn[_column][_currentpos].y};
-    return p;
-}  
\ No newline at end of file
+
+    Vector2D alienxy = {_board.drawcolumn[_column][_currentpos].x, _board.drawcolumn[_column][_currentpos].y};
+    return alienxy;
+}  
+
+//returns the column and position in the lane of the alien
+Vector2D Alien::getcolumnpos() {
+    Vector2D aliencolpos = {_column, _currentpos};
+    return aliencolpos;   
+}
\ No newline at end of file