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.
Diff: main.cpp
- Revision:
- 4:0f2006e9c8f8
- Parent:
- 1:538386e72e40
diff -r ccbda43c2124 -r 0f2006e9c8f8 main.cpp
--- a/main.cpp Wed May 08 22:18:51 2019 +0000
+++ b/main.cpp Thu May 09 02:37:14 2019 +0000
@@ -32,19 +32,16 @@
///////////// MAIN.CPP ////////////////
int main () {
- int fps = 1;
+ int fps = 0; // initial fps, fps will be update by function menu.difficulty(lcd,pad).
initial();
welcome();
- menu.menus(lcd,pad);
+ menu.menus(lcd,pad);// settings or start game
fps = menu.difficulty(lcd,pad);
render();
- move.getfood();
+ move.getfood(); // generate food
while(1) {
- //process_input();
- //update_game_state();
- //refresh_display();
- //wait_ms(1000/fps);
- move.eatfood();
+
+ move.eatfood(); //check is food is hit by snake head, if yes , generate a new one
move.update(pad);
move.updatebody();
@@ -72,7 +69,7 @@
void welcome() {
lcd.printString(" snake! ",0,1);
- lcd.printString(" Press Start ",0,4);
+ lcd.printString("( Press Start)",0,4);
lcd.refresh();
while ( pad.check_event(Gamepad::START_PRESSED) == false) {