Rex Raj / Mbed 2 deprecated el17rrrs

Dependencies:   mbed Gamepad N5110 mbed-rtos

Revision:
4:4d673fb2d9dc
Parent:
3:bf9624e5b0c3
Child:
5:016a7315b75d
diff -r bf9624e5b0c3 -r 4d673fb2d9dc Enemy/EnemyBoss.cpp
--- a/Enemy/EnemyBoss.cpp	Thu Apr 25 16:31:27 2019 +0000
+++ b/Enemy/EnemyBoss.cpp	Sun May 05 17:41:46 2019 +0000
@@ -11,8 +11,7 @@
 
 }       
 
-AnalogIn noisy(PTB0);
-
+// sprite of the third-(one&two) enemy
 int enemy2 [7][8] = {
    
 {0,1,1,0,0,0,0,1},
@@ -25,6 +24,7 @@
 
 };
 
+// sprite of the third-boss enemy
 int boss [13][13] = {
     
 {0,0,0,0,0,1,1,1,1,1,0,0,0},
@@ -43,24 +43,24 @@
 
 };
 
-void EnemyBoss::init(int a,int b,int c,int d,int e,int f,int speed)
+void EnemyBoss::init(int a,int b,int c,int d,int e,int f,int speed) // initialising the x and y position of the third enemy and movement speed of the third enemy
 {
   
-    _a = a;
-    _b = b;
-    _c = c;
-    _d = d;
-    _e = e;
-    _f = f;
+    _a = a; // x position of the boss enemy for stage 3
+    _b = b; // y position of the boss enemy for stage 3
+    _c = c; // x position of the first regular enemy for stage 3
+    _d = d; // y position of the first regular enemy for stage 3
+    _e = e; // x position of the second regular enemy for stage 3
+    _f = f; // y position of the second regular enemy for stage 3
     
-    _health = 0;  // start health from zero
-    _health1 = 0;
-    _health2 = 0;
+    _health = 0;  // start health from zero for boss
+    _health1 = 0; // start health from zero for first enemy
+    _health2 = 0; // start health from zero for second enemy
 
-    rand(100000*noisy.read());
+    rand(time(NULL));
     int direction = rand() % 8; // randomise initial direction. 
     
-    // 4 possibilities. Get random modulo and set movement accordingly
+    // 8 possibilities. Get random modulo and set movement accordingly
     if (direction == 0) {
         _movement.x = speed;
         _movement.y = speed;
@@ -91,91 +91,112 @@
 void EnemyBoss::enemyboss(N5110 &lcd)
 {
 
-    // draw the second-one enemy
+    // draws the boss enemy for stage 3
     lcd.drawSprite(_a,_b,13,13,(int *)boss);
+    // draws the first regular enemy for stage 3
     lcd.drawSprite(_c,_d,7,8,(int *)enemy2);
+    // draws the first regular enemy for stage 3
     lcd.drawSprite(_e,_f,7,8,(int *)enemy2);
     
 }
 
 void EnemyBoss::update()
 {
-    _a += _movement.x;
-    _b += _movement.y; 
+    _a += _movement.x; // updates the x position for the boss enemy
+    _b += _movement.y; // updates the y position for the boss enemy
+    
+    // the first and second regular enemy stay stationery 
 }
 
 
 Vector2D EnemyBoss::get_movement()
 {
+    // gets the movement of the boss enemy
     Vector2D m = {_movement.x,_movement.y};
     return m;
 }
 
 void EnemyBoss::set_movement(Vector2D m)
 {
+    // sets the movement of the boss enemy
     _movement.x = m.x;
     _movement.y = m.y;
 }
   
 void EnemyBoss::add_health_boss()
 {
+    // increments the value of health by 1 for the boss enemy
     _health++;
 }
 
 int EnemyBoss::get_health_boss()
 {
+    // gets the value of boss health
     return _health;
 }
 
 void EnemyBoss::add_health_enemy1()
 {
+    // increments the value of health by 1 for the first regular enemy
     _health1++;
 }
 
 int EnemyBoss::get_health_enemy1()
 {
+   // gets the value of first regular enemy health
     return _health1;
 }
 
 void EnemyBoss::add_health_enemy2()
 {
+     // increments the value of health by 1 for the second regular enemy
     _health2++;
 }
 
 int EnemyBoss::get_health_enemy2()
 {
+    // gets the value of second regular enemy health
     return _health2;
 }
 
-Vector2D EnemyBoss::get_enemyboss_pos() {
+Vector2D EnemyBoss::get_enemyboss_pos() 
+{
+    //gets the position of the boss enemy for stage 3
     Vector2D e = {_a,_b};
     return e;    
 }
 
-Vector2D EnemyBoss::get_enemy1_pos() {
+Vector2D EnemyBoss::get_enemy1_pos() 
+{
+    //gets the position of the first regular enemy for stage 3
     Vector2D d = {_c,_d};
     return d;    
 }
 
-Vector2D EnemyBoss::get_enemy2_pos() {
+Vector2D EnemyBoss::get_enemy2_pos() 
+{
+    //gets the position of the second regular enemy for stage 3
     Vector2D c = {_e,_f};
     return c;    
 }
 
 void EnemyBoss::set_enemyboss_pos(Vector2D e)
 {
+    //sets the position of the boss enemy for stage 3
     _a = e.x;
     _b = e.y;
 }
 
 void EnemyBoss::set_enemy1_pos(Vector2D d)
 {
+    //sets the position of the first regular enemy for stage 3
     _c = d.x;
     _d = d.y;
 }
 
 void EnemyBoss::set_enemy2_pos(Vector2D c)
 {
+    //gets the position of the second regular enemy for stage 3
     _e = c.x;
     _f = c.y;
 }
\ No newline at end of file