Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Hero/Hero.cpp
- 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) {