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 Gamepad N5110
Diff: main.cpp
- Revision:
- 25:230e4163cb6b
- Parent:
- 24:f5dd1f3db693
- Child:
- 26:3319ddd5111d
diff -r f5dd1f3db693 -r 230e4163cb6b main.cpp
--- a/main.cpp Sun Apr 21 18:17:20 2019 +0000
+++ b/main.cpp Sun Apr 21 19:50:39 2019 +0000
@@ -4,19 +4,19 @@
#include "Runner.h"
#include "Levels.h"
#include "Animation.h"
+#include "BlockheadEngine.h"
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
-Runner runner;
-Animation ani;
-Levels lev;
+BlockheadEngine blockhead;
Ticker ticker;
volatile int timer_flag = 0;
void timer_isr();
-
+int user_input(Gamepad &pad);
+void select_menu_item(int input);
int main()
{
@@ -26,11 +26,6 @@
pad.init();
lcd.init();
lcd.setContrast(0.55);
- Move move;
- Pos pos;
-
- move = runner.init(move);
- pos = lev.init(pos);
ticker.attach(&timer_isr,1.0f/fps);
@@ -44,10 +39,7 @@
lcd.clear();
- move = runner.nextLevel(move);
- pos = lev.whatLevel(lcd, move.l);
- move = runner.blockhead(move, pos, lcd, pad);
- gameover = runner.gameover(move, pos, lcd);
+ gameover = blockhead.playgame(lcd, pad);
lcd.refresh();
@@ -66,6 +58,43 @@
timer_flag = 1; // set flag in ISR
}
+int user_input(Gamepad &pad)
+{
+ int input;
+
+
+ if (pad.check_event(Gamepad::A_PRESSED)) {
+ input = 1;
+ } else if (pad.check_event(Gamepad::B_PRESSED)) {
+ input = 2;
+ } else {
+ input = 0;
+ }
+
+ return input;
+}
+
+void select_menu_item(int input) {
+ switch (input) {
+ case 1:
+ menu_item_1();
+ break;
+ case 2:
+ menu_item_2();
+ break;
+ default:
+ exit(1);
+ break;
+ }
+}
+
+void menu_playgame(N5110 &lcd, Gamepad &pad)
+{
+
+
+
+
+
//rtos
/**