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:
- 8:c3cf8d1057bb
- Parent:
- 7:b54323241435
- Child:
- 9:35f992fd407b
--- a/main.cpp Tue May 02 00:20:44 2017 +0000
+++ b/main.cpp Wed May 03 14:25:55 2017 +0000
@@ -1,18 +1,19 @@
#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
-#include "Player.h"
#include "GameEngine.h"
-#include "Menu.h"
+#include "MenuEngine.h"
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Serial pc(USBTX, USBRX); // tx, rx
Gamepad pad;
GameEngine game;
-Player player;
-Menu menu;
+MenuEngine menu;
void update_screen();
+void welcome();
+
+bool showStart = true;
int main()
{
@@ -21,15 +22,50 @@
lcd.normalMode();
lcd.setBrightness(1);
- game.init(4);
- lcd.refresh();
- while(1) { // loop forever
+ while (!pad.check_event(Gamepad::START_PRESSED)) {
+ welcome();
+ }
- game.read_input(pad,pc);
- game.update(pad, pc, lcd);
- game.draw(lcd);
+ while(1)
+ {
+ menu.init();
+ while (!menu.gameStarted)
+ {
+ menu.read_input(pad, pc);
+ menu.update(pad, pc, lcd);
+ menu.draw(lcd,pc);
+ menu.check_finish(pad, lcd, pc);
+ wait(1.0f/10);
+ }
+ game.init(menu.selectedLevel, menu.soundIsOn, pad);
+ while (game.isActive)
+ {
+ game.read_input(pad,pc);
+ game.update(pad, pc, lcd);
+ game.draw(lcd);
+ game.check_finish(pad, lcd);
+ wait(1.0f/10); // 10 fps
+ }
+ }
+}
- wait(1.0f/10); // 10 fps
+void welcome()
+{
+ lcd.clear();
+ lcd.printString("Escape", 5, 0);
+ lcd.printString("is", 30, 1);
+ lcd.printString("an", 35, 2);
+ lcd.printString("Ellusion", 30, 3);
+ if (showStart)
+ {
+ lcd.printString("Press START", 10, 5);
+ showStart = false;
}
+ else
+ {
+ showStart = true;
+ }
+ lcd.refresh();
+ wait(0.5);
}
\ No newline at end of file