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:1e4182ebb063
- Parent:
- 7:c67a5c6a874f
- Child:
- 9:f0213e632379
--- a/main.cpp Thu May 21 13:55:57 2020 +0000
+++ b/main.cpp Thu May 21 14:16:51 2020 +0000
@@ -16,6 +16,7 @@
#include "N5110.h"
#include "SnakeHead.h"
#include "SnakeTail.h"
+#include "GameEngine.h"
// objects
@@ -23,6 +24,11 @@
N5110 lcd;
SnakeHead head;
SnakeTail tail;
+GameEngine engine;
+
+//
+#define HEAD_SIZE 1
+#define HEAD_SPEED 3
void welcome();
void init();
@@ -33,7 +39,8 @@
int fps = 6;
//initialise objects
init();
- head.init(1,3);
+ engine.init(HEAD_SIZE, HEAD_SPEED);
+ //head.init(1,3);
//render first frame
@@ -41,7 +48,7 @@
wait(3.0);
lcd.clear();
- head.draw(lcd);
+ //head.draw(lcd);
lcd.refresh();
while(1) {
@@ -70,16 +77,12 @@
} else if (pad.A_pressed() == false) {
printf("start not pressed\n");
}*/
- Direction _d = pad.get_direction();
- head.change_direction(_d);
- //tail.set_length(2);
- Vector2D headPos = head.get_pos();
- head.update();
- //tail.update(headPos);
+
+
+ engine.read_input(pad);
+ engine.update(pad, lcd);
lcd.clear();
- head.draw(lcd);
- //tail.draw(lcd);
- //tail.draw_tail(lcd, head, _d);
+ engine.draw(lcd);
lcd.refresh();