The game is finished

Dependencies:   mbed Gamepad N5110 mbed-rtos

Revision:
7:574c66ebd8b0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MiniEnemy/MiniEnemy.cpp	Thu May 09 09:54:50 2019 +0000
@@ -0,0 +1,123 @@
+#include "MiniEnemy.h"
+
+// nothing doing in the constructor and destructor
+MiniEnemy::MiniEnemy()
+{
+
+}
+
+MiniEnemy::~MiniEnemy()
+{
+
+}       
+
+// first enemy sprite
+int e1 [7][8] = {
+   
+{0,1,1,0,0,0,0,1},
+{0,0,0,1,1,1,1,1},
+{0,0,1,0,0,1,1,0},
+{0,1,0,0,1,1,1,0},
+{0,0,1,0,0,1,1,0},
+{0,0,0,1,1,1,1,1},
+{0,1,1,0,0,0,0,1},
+
+};
+
+void MiniEnemy:: init() 
+{
+   _score = 0;  // initial score
+   _fast  = 1;  // initial speed
+   _health = 0; // initial health
+}  
+  
+Vector2D MiniEnemy::location()
+{
+    
+    int a = rand() % 33; // randomise initial direction. 
+    int b = rand() % 40; // randomise initial direction.
+    
+    _location.x = a + 42; // starts from halfway of the screen 
+    _location.y = b;
+    
+    Vector2D velocity = {_location.x, _location.y};
+    return velocity;
+}
+
+void MiniEnemy::enemy(N5110 &lcd)
+{
+
+    // draws the first enemy
+    lcd.drawSprite(_location.x,_location.y,7,8,(int *)e1);
+}
+
+void MiniEnemy::update() // moves the position of the enemy when the enemy dies
+{
+
+    _location.x -=_fast; // moves the y-position downwards
+  
+  
+}
+void MiniEnemy::add_score()
+{
+    // increments the value of score by 1
+    _score++;
+}
+int MiniEnemy::get_score()
+{
+    // gets the value of score
+    return _score;
+}
+
+void MiniEnemy::add_health()
+{
+    // increments the value of score by 1
+    _health++;
+}
+
+void MiniEnemy::add_fast()
+{
+    // increments the value of fast by 1
+    if (_fast <= 7){
+    _fast++;
+    }
+}
+
+int MiniEnemy::get_fast()
+{
+    // gets the value of score
+    return _fast;
+}
+
+int MiniEnemy::set_fast()
+{
+    // sets the fast to be zero
+    _fast = 0;
+     return _fast;
+}
+   
+int MiniEnemy::get_health()
+{
+    // gets the value of score
+    return _health;
+}
+
+int MiniEnemy::set_health()
+{
+    // sets the health to be zero 
+    _health = 0;
+     return _health;
+}
+   
+Vector2D MiniEnemy::get_enemy_pos() {
+    //gets the position of the first enemy
+    Vector2D e = {_location.x,_location.y};
+    return e;    
+}
+
+void MiniEnemy::set_enemy_pos(Vector2D e)
+{
+    //sets the position of the first enemy of stage 2
+    _location.x = e.x;
+    _location.y = e.y;
+}
\ No newline at end of file