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:
- 16:4d329ce7b156
- Parent:
- 15:130900e5c268
diff -r 130900e5c268 -r 4d329ce7b156 main.cpp
--- a/main.cpp Tue May 08 14:06:47 2018 +0000
+++ b/main.cpp Tue May 08 14:41:56 2018 +0000
@@ -59,6 +59,7 @@
///////////// functions ////////////////
int main()
{
+ printf("Loaded\n");
init();
welcome();
@@ -84,6 +85,8 @@
void welcome()
{
+ printf("Welcome Screen\n");
+
lcd.printString(" Snake! ",0,1);
lcd.printString(" Press Start ",0,4);
lcd.refresh();
@@ -106,6 +109,8 @@
lcd.init();
pad.init();
mainMenu.init();
+
+ printf("Initialised\n");
}
@@ -113,6 +118,8 @@
{
mainMenu.init(); //resets both the mainMenu and gameEngine
gameEngine.init(); //the gameEngine will reset the food and the snake in the process
+
+ printf("Reset\n");
}
void renderGame()
@@ -122,6 +129,8 @@
gameEngine.draw(lcd);
lcd.refresh();
wait(setDif()); //adaptive fps depending on difficulty
+
+ printf("Game Rending\n");
}
void renderMenu()
@@ -131,12 +140,16 @@
mainMenu.draw(lcd);
lcd.refresh();
wait(1.0f/8); //fixed at 8 fps
+
+ printf("Menu Rending\n");
}
void transition()
{
//transition animation between modes to reduce 'ghosting' of inputs
+ printf("Transisitoning\n");
+
for (int i = 0; i <= 11; i++) { //max values for i and j were chosen as the screen is 84x44 and the sqaures being drawn are 4x4
for (int j = 0; j <= 21; j++) {
lcd.drawRect(j*4,i*4,4,4,FILL_BLACK); //covers the entire screen in 4x4 squares
@@ -159,6 +172,9 @@
return 1.0f/12;
} else { //Adaptive difficulty
float _delta = gameEngine.getScore();
+
+ printf("Delta %4.2f\n", _delta);
+
if (_delta < 25) { //Limits FPS to 25
return ((1.0f/(_delta + 1))); //changes the fps depending on score
} else {