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.
Hero/Hero.cpp@8:d1c04f0e4890, 2019-05-11 (annotated)
- Committer:
- el17ttds
- Date:
- Sat May 11 08:23:54 2019 +0000
- Revision:
- 8:d1c04f0e4890
- Parent:
- 7:08f78909dda7
- Child:
- 9:3a0194c87afe
Full game.; Unfinished menu, tone glitch, score doesn't print, ammo and health to be displayed
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| el17ttds | 2:ee9b361ba6df | 1 | #include "Hero.h" | 
| el17ttds | 2:ee9b361ba6df | 2 | |
| el17ttds | 2:ee9b361ba6df | 3 | Hero::Hero() { | 
| el17ttds | 2:ee9b361ba6df | 4 | |
| el17ttds | 2:ee9b361ba6df | 5 | } | 
| el17ttds | 2:ee9b361ba6df | 6 | |
| el17ttds | 3:3d35ab70b565 | 7 | void Hero::init(int swidth, int sheight) { | 
| el17ttds | 3:3d35ab70b565 | 8 | _x = swidth / 2; | 
| el17ttds | 3:3d35ab70b565 | 9 | _y = sheight / 2; | 
| el17ttds | 7:08f78909dda7 | 10 | // frame_counter = 0; | 
| el17ttds | 7:08f78909dda7 | 11 | _health = 3; | 
| el17ttds | 7:08f78909dda7 | 12 | // _health_rate = 50; possible addition | 
| el17ttds | 7:08f78909dda7 | 13 | } | 
| el17ttds | 7:08f78909dda7 | 14 | |
| el17ttds | 8:d1c04f0e4890 | 15 | void Hero::health(bool collision, Gamepad &pad) { | 
| el17ttds | 7:08f78909dda7 | 16 | // frame_counter++; | 
| el17ttds | 7:08f78909dda7 | 17 | if (collision == true) { | 
| el17ttds | 7:08f78909dda7 | 18 | _health--; | 
| el17ttds | 7:08f78909dda7 | 19 | pad.tone(1500, 0.2); | 
| el17ttds | 7:08f78909dda7 | 20 | } | 
| el17ttds | 8:d1c04f0e4890 | 21 | // if ( (frame_counter <= _health_rate) && (health < 4) ) { _health++;} // increase health over time | 
| el17ttds | 2:ee9b361ba6df | 22 | } | 
| el17ttds | 2:ee9b361ba6df | 23 | |
| el17ttds | 2:ee9b361ba6df | 24 | void Hero::draw(N5110 &lcd) { | 
| el17ttds | 8:d1c04f0e4890 | 25 | lcd.drawCircle( _x, _y, 5, FILL_TRANSPARENT); | 
| el17ttds | 6:e8c03f264ffc | 26 | } | 
| el17ttds | 8:d1c04f0e4890 | 27 | |
| el17ttds | 8:d1c04f0e4890 | 28 | int Hero::get_health() { | 
| el17ttds | 8:d1c04f0e4890 | 29 | return _health; | 
| el17ttds | 8:d1c04f0e4890 | 30 | } |