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:
- 13:4026781772cb
- Parent:
- 9:f82627d119f6
- Child:
- 15:47ea86f1ed70
--- a/main.cpp Fri May 04 13:25:18 2018 +0000
+++ b/main.cpp Sun May 06 12:44:41 2018 +0000
@@ -11,11 +11,12 @@
#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
-#include "Snake.h"
+#include "snake.h"
+#include "snake_engine.h"
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
-
+snake_engine engine;
struct UserInput {
Direction d;
@@ -26,6 +27,62 @@
void init();
void render();
void welcome();
+void reset();
+
+int main()
+{
+ init();
+ welcome();
+ while (1) {
+
+ engine.read_input(pad);
+ engine.update(pad, lcd);
+ render();
+ wait(0.05f);
+ reset();
+ }
+}
+
+
+void init()
+{
+ lcd.init();
+ pad.init();
+ engine.init();
+}
+
+
+void render()
+{
+
+ lcd.clear();
+ engine.draw(lcd);
+ lcd.refresh();
+}
+
+
+
+
+void welcome()
+{
+
+ while ( pad.check_event(Gamepad::START_PRESSED) == false) {
+ }
+
+}
+
+
+
+void reset()
+{
+ if ( pad.check_event(Gamepad::BACK_PRESSED) == true) {
+ lcd.clear();
+ lcd.refresh();
+
+ init();
+ welcome();
+ }
+}
@@ -56,3 +113,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+