ELEC2645 (2018/19) / Mbed 2 deprecated el17ttds

Dependencies:   mbed N5110_tf

Revision:
7:08f78909dda7
Parent:
6:e8c03f264ffc
Child:
8:d1c04f0e4890
--- a/Hero/Hero.cpp	Wed May 08 19:05:36 2019 +0000
+++ b/Hero/Hero.cpp	Thu May 09 01:30:57 2019 +0000
@@ -7,6 +7,23 @@
 void Hero::init(int swidth, int sheight) {
   _x = swidth / 2;
   _y = sheight / 2;
+  // frame_counter = 0;
+  _health = 3;
+  // _health_rate = 50; possible addition
+}
+
+bool Hero::health(bool collision, Gamepad &pad) {
+  // frame_counter++;
+  if (collision == true) {
+    _health--;
+    pad.tone(1500, 0.2);
+  }
+  // if ( (frame_counter <= _health_rate) && (health < 4) ) { // increase health over time
+  if (_health <= 0) {
+    return false;
+  } else {
+    return true;
+  }
 }
 
 void Hero::draw(N5110 &lcd) {