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:
- 18:ff0a53dcb862
- Parent:
- 17:b4079bd0e551
- Child:
- 19:4789cb4ca550
diff -r b4079bd0e551 -r ff0a53dcb862 Gameengine.cpp
--- a/Gameengine.cpp Mon Apr 01 14:59:18 2019 +0000
+++ b/Gameengine.cpp Mon Apr 01 21:51:08 2019 +0000
@@ -12,6 +12,7 @@
{
_level_select = 1;
_miner.miner_init(3, 33);
+ _lives = 3;
}
void Gameengine::read_direction(Gamepad &pad)
@@ -25,37 +26,30 @@
_miner.miner_gravity(lcd);
_miner.miner_jump(lcd, pad);
_miner.miner_land(lcd);
-
-
+ lose_life(lcd);
}
void Gameengine::draw(N5110 &lcd)
{
- if (_level_select == 1){
+ if (_level_select == 1) {
_miner.miner_draw(lcd);
- _level.level_one(lcd);
- _level.soft_blocks(46, 8, lcd);
- _level.soft_blocks(52, 8, lcd);
- _level.soft_blocks(55, 36, lcd);
- _level.soft_blocks(33, 8, lcd);
- _level.soft_blocks(27, 8, lcd);
- _level.soft_blocks(59, 36, lcd);
- _level.draw_solid_block(49,37, lcd);
- _level.draw_solid_block(52,37, lcd);
- _level.draw_solid_block(45,22, lcd);
- _level.draw_solid_block(42,22, lcd);
- _miner.level_one_collision(lcd);
-
- //level keys
- _level.draw_key1(79, 12, lcd);
- _level.draw_key2(25, 0, lcd);
- _level.draw_key3(40, 4, lcd);
- _level.draw_key4(56, 6, lcd);
- _level.draw_key5(75, 0, lcd);
- _level.keys_collected();
-
- printf("game keys = %i \n ", _level.keys_collected());
-
+ _l1.level_platforms(lcd);
+ _l1.soft_blocks(lcd);
+ _l1.solid_blocks(lcd);
+ _l1.keys(lcd);
+ _l1.keys_collected();
+ _l1.spikes(lcd);
}
}
-
\ No newline at end of file
+
+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);
+}
\ No newline at end of file