ELEC2645 (2018/19) / Mbed 2 deprecated el17dg

Dependencies:   mbed

Fork of el17dg by Dmitrijs Griskovs

Revision:
23:240bc00ef25b
Parent:
21:0eb394495b8a
Child:
24:0570cb4b92d7
diff -r 4dc3c95f2146 -r 240bc00ef25b game/enemies.h
--- a/game/enemies.h	Wed Mar 27 16:35:52 2019 +0000
+++ b/game/enemies.h	Sun Mar 31 01:04:59 2019 +0000
@@ -9,16 +9,26 @@
 const int max_enemy_blasts = max_enemies * 5;
 const int enemy_blast_speed = 5;
 
+    
+
 class Enemy : public GameObject {
 public:
+/**@brief
+  * This function spawns an enemy on the right side of the screen at the 
+  * x-direction LCD limit(84) and at random position in the y-direction.
+  */
     void spawn() {
+        // giving the enemy the spawning positions 
         Point spawn_pos(screen_width, game_area_y + rand() % (game_area_height - enemy2_height));
         GameObject::spawn(spawn_pos);
         dead = false;
         dead_counter = 0;
         blast_countdown = 0;
     }
-    
+/**@brief
+  * This is a death function of an nemy when the the collision between the 
+  * player blast and enemy ship is true. It sets the enemy ship to not active.
+  */
     void die() {
         dead = true;
         dead_counter = 3;
@@ -54,8 +64,16 @@
     int blast_countdown;
 };
 
+    
+
 class Enemies {
 public:
+
+    Enemy enemy_blasts[max_enemy_blasts];
+    Enemy enemies[max_enemies];
+    CircleBounds enemy_bounds;
+    CircleBounds enemy_blast_bounds;
+    
     Enemies () {
         enemy_bounds.center.x = 5;
         enemy_bounds.center.y = 3;
@@ -109,6 +127,7 @@
             enemy_blasts[found].active = true;
             enemy_blasts[found].pos.x = enemy.pos.x;
             enemy_blasts[found].pos.y = enemy.pos.y + enemy2_height / 2;
+            gamepad.tone(500,0.1);
             return true;
         }
         return false;
@@ -129,11 +148,6 @@
         }
     }
     
-    
-    GameObject enemy_blasts[max_enemy_blasts];
-    Enemy enemies[max_enemies];
-    CircleBounds enemy_bounds;
-    CircleBounds enemy_blast_bounds;
 };
 
 #endif
\ No newline at end of file