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:
- 9:25597bc0cecc
- Parent:
- 8:32825d724856
- Child:
- 10:3e37b58e8600
--- a/main.cpp Fri Jun 05 06:29:17 2020 +0000
+++ b/main.cpp Fri Jun 05 10:51:30 2020 +0000
@@ -19,10 +19,9 @@
#include "Snake.h"
#include "Apple.h"
-#define SCORE 6
-#define APPLE_SIZE 3
+#define APPLE_SIZE 2
#define SNAKE_SPEED 1
-
+#define SNAKE_SCORE 0
/////////////// structs /////////////////
@@ -30,6 +29,10 @@
Direction d;
float mag;
};
+
+
+
+
/////////////// objects ///////////////
N5110 lcd;
Gamepad pad;
@@ -46,10 +49,10 @@
int main()
{
- int fps = 6; // frames per second
+ int fps = 6; // How many Frames Per Second (FPS)
- init(); // initialise and then display welcome screen...
- welcome(); // waiting for the user to start
+ init(); // turns on LCD and PAD
+ welcome(); // Waits for input
render(); // first draw the initial frame
wait(1.0f/fps); // and wait for one frame period
@@ -70,18 +73,19 @@
// need to initialise LCD and Gamepad
lcd.init();
pad.init();
+ snake.init(APPLE_SIZE,SNAKE_SCORE, SNAKE_SPEED);
}
// this function draws each frame on the LCD
void render()
{
- // clear screen, re-draw and refresh
+ // Each time we render we need to clear screen get the buffer and refresh
lcd.clear();
snake.draw(lcd);
lcd.refresh();
}
-// simple splash screen displayed on start-up
+// Welcome Screen
void welcome() {
pad.led(3,1); // Only Show Green LEDS
pad.led(6,1); //