ELEC2645 (2018/19) / Mbed 2 deprecated el17aio

Dependencies:   mbed

Revision:
28:6319e928f0aa
Parent:
27:f99249e727fd
Child:
29:4c7b16b5b6df
--- a/RosenEngine/RosenEngine.cpp	Thu Apr 18 13:57:41 2019 +0000
+++ b/RosenEngine/RosenEngine.cpp	Thu Apr 18 20:09:29 2019 +0000
@@ -76,18 +76,36 @@
     }
     // _menu.update(_d);
 
-    if(enemy_ship_collision() == true){
-        _health.update(1);
+    if(enemy_ship_collision() == true) {
+        _health.update(1,pad);
         _enemy.reset_seeker();
-        }
-    if(enemy_projectile_collision() == true){
+        pad.tone(500,0.05);
+        wait(0.05);
+    }
+    if(enemy_projectile_collision() == true) {
         _enemy.reset_seeker();
-            pad.tone(1000,0.05);
-            wait(0.05);
-            pad.tone(1500,0.05);
-            wait(0.05);
+        pad.tone(1000,0.05);
+        wait(0.05);
+        pad.tone(1500,0.05);
+        wait(0.05);
+    }
+    // printf("collision check complete");
+    
+    // warning sound
+    Vector2D hp = _health.get_hp();
+    int health = hp.x;
+    if(_shipno == 0 || 1) {
+        if(health <= 2 ) {
+            pad.tone(1300,0.1);
+            wait(0.1);
         }
-    // printf("collision check complete");
+    }
+    if(_shipno == 2) {
+        if(health <= 1 ) {
+            pad.tone(1300,0.1);
+            wait(0.1);
+        }
+    }
 }
 void RosenEngine::get_pos()
 {
@@ -230,12 +248,11 @@
         }
         if(wxcol == 1 && A == true) {
             return true;
-        }
-        else{
+        } else {
             return false;
         }
     }
     if(_shipno == 2) {
         return false;
-        }
+    }
 }
\ No newline at end of file