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: main.cpp
- Revision:
- 21:7d4827af00d6
- Parent:
- 19:1073cc64cb0b
- Child:
- 22:8e38efeae0c9
--- a/main.cpp Wed May 08 18:36:45 2019 +0000
+++ b/main.cpp Wed May 08 23:17:35 2019 +0000
@@ -4,18 +4,9 @@
#include "Game.h"
#include "Menu.h"
-struct joystick_val {
- Direction dir;
- float mag;
-};
-
Game game;
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
-Smiley smiley;
-Coin coin;
-Enemy1 enemy1;
-Menu menu;
void init();
void render();
@@ -25,20 +16,24 @@
int fps = 30;
lcd.setContrast(0.4);
- lcd.setBrightness(0.5);
+ lcd.setBrightness(1);
+
init();
startScreen();
//game.UI(pad,lcd);
//render();
wait(1.0f/fps);
+
while (1) {
game.UI(pad,lcd);
game.init();
int lives = game.get_lives();
- while (lives > 0) {
+ int coins = game.get_coins();
+ while (lives > 0 || coins < 1) {
render();
wait(1.0f/fps);
lives = game.get_lives();
+ coins = game.get_coins();
}
}
}
@@ -52,10 +47,11 @@
lcd.clear();
game.dirmag(pad);
game.drawSprite(lcd);
- game.movement(pad,lcd);
- game.collect(lcd, pad);
+ game.movement(lcd,pad);
+ game.collect(lcd,pad);
game.damage(lcd,pad);
- game.death(lcd,pad);
+ game.death(lcd);
+ game.win(lcd);
game.display_health(lcd);
lcd.refresh();
}