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.
Dependencies: mbed
Diff: Gameengine.cpp
- Revision:
- 19:4789cb4ca550
- Parent:
- 18:ff0a53dcb862
- Child:
- 20:78bd235f8caa
diff -r ff0a53dcb862 -r 4789cb4ca550 Gameengine.cpp
--- a/Gameengine.cpp Mon Apr 01 21:51:08 2019 +0000
+++ b/Gameengine.cpp Mon Apr 01 23:55:24 2019 +0000
@@ -21,17 +21,21 @@
}
void Gameengine::update(N5110 &lcd, Gamepad &pad)
-{
+{
+ t.start();
+ read_direction(pad);
_miner.miner_move(_d);
_miner.miner_gravity(lcd);
_miner.miner_jump(lcd, pad);
_miner.miner_land(lcd);
lose_life(lcd);
+ game_over();
}
void Gameengine::draw(N5110 &lcd)
{
if (_level_select == 1) {
+
_miner.miner_draw(lcd);
_l1.level_platforms(lcd);
_l1.soft_blocks(lcd);
@@ -44,12 +48,21 @@
void Gameengine::lose_life(N5110 &lcd)
{
-
+
if (_l1.spikes(lcd) == 1) {
_lives--;
- printf("lives = %i", _lives);
_miner.miner_init(3, 33);
wait(0.5);
}
- printf("lives = %i", _lives);
+}
+
+bool Gameengine::game_over()
+{
+ printf("The time taken was %f seconds\n", t.read());
+ if(_lives == 0 || t.read() > 10){
+ t.stop();
+ return true;
+ } else {
+ return false;
+ }
}
\ No newline at end of file