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 ll16j23s_test_docs
Revision 14:2dfe04ced21c, committed 2020-05-27
- Comitter:
 - JoeShotton
 - Date:
 - Wed May 27 03:18:16 2020 +0000
 - Parent:
 - 13:7b7ec5db56b2
 - Commit message:
 - Final Version
 
Changed in this revision
--- a/Food/Food.cpp	Wed May 27 00:59:14 2020 +0000
+++ b/Food/Food.cpp	Wed May 27 03:18:16 2020 +0000
@@ -21,7 +21,7 @@
     srand(_seed);
     while (rand_pos(pad, lcd) == false){ //while new food coordinates are in the snake/walls
         rand_pos(pad, lcd);              //choose new coords by rerunning the function
-        printf("Reselected food position\n");
+        //printf("Reselected food position\n");
     }
 }
 
@@ -45,6 +45,7 @@
     // draw food, with alternating pixels depending on frame. 
     _frame++;
     _frame = _frame % 12;
+    //printf("Food frame: %d\n", _frame);
     if (_frame > 6) { 
         lcd.drawLine(x, y, x + 1, y + 1, 1);
     } else {
--- a/Food/Food.h Wed May 27 00:59:14 2020 +0000 +++ b/Food/Food.h Wed May 27 03:18:16 2020 +0000 @@ -6,7 +6,7 @@ #include "Gamepad.h" #include "FXOS8700CQ.h" -/** SnakeEngine Class: +/** SnakeEngine: @brief - Functions that exclusively control the food @author Joseph Shotton @date May 2020
--- a/SnakeBody/SnakeBody.cpp	Wed May 27 00:59:14 2020 +0000
+++ b/SnakeBody/SnakeBody.cpp	Wed May 27 03:18:16 2020 +0000
@@ -92,6 +92,7 @@
     if(_length_increase > 0) { //converts length increase into length, one unit at a time
         _length++;
         _length_increase--;
+        //printf("L increase: %d\n", _length_increase);
     }
 }
 
@@ -133,7 +134,7 @@
 {
     head_x = 42;
     head_y = 24;
-    for(int i = 3; i < body_y.size(); i++) { 
+    for(int i = 1; i < body_y.size(); i++) { 
         body_y.at(i) = 50; //moves all body coordinates off-screen
     }
     _length = 4;
--- a/SnakeBody/SnakeBody.h Wed May 27 00:59:14 2020 +0000 +++ b/SnakeBody/SnakeBody.h Wed May 27 03:18:16 2020 +0000 @@ -6,7 +6,7 @@ #include "Gamepad.h" #include <vector> -/** SnakeBody Class: +/** SnakeBody: @brief - Functions that exclusively control the snake body @author Joseph Shotton @date May 2020
--- a/SnakeEngine/SnakeEngine.cpp	Wed May 27 00:59:14 2020 +0000
+++ b/SnakeEngine/SnakeEngine.cpp	Wed May 27 03:18:16 2020 +0000
@@ -37,8 +37,7 @@
         //printf("Dead!");        
         game_state = 4;         //sets game_state to death, which changes the active while loop in main.cpp
         death_init(pad, lcd);   //displays death menu
-    }
-    //snake-wall collision 
+    } 
 } 
 
 void SnakeEngine::snake_food_collision(Gamepad &pad, N5110 &lcd) {
@@ -58,7 +57,7 @@
 }
 
 void SnakeEngine::map_run(N5110 &lcd) {
-    switch(_map_select+1) { //selects chosen map
+    switch(_map_select + 1) { //selects chosen map
         case 2:
             map2_draw(lcd);
             snake_map2_collision();    
@@ -176,7 +175,7 @@
          transition_black(lcd); 
          transition_white(lcd);
          lcd.refresh();
-         //printf("Menu 2\n");
+         //printf("Menu 1\n");
          lcd.printString("SNAKE",27,0); //displays relevant text
          lcd.printString("Play",30,2);
          lcd.drawCircle(24,19,3,FILL_TRANSPARENT); //draws empty circles for option display 
@@ -277,7 +276,8 @@
             game_init(pad, lcd, mag); 
             game_state = 3;   
         } else {
-            menu2_init(pad, lcd);    
+            menu2_init(pad, lcd);
+            menu_flash(pad, 2);    
             game_state = 2;    
         }
     }
--- a/SnakeEngine/SnakeEngine.h Wed May 27 00:59:14 2020 +0000 +++ b/SnakeEngine/SnakeEngine.h Wed May 27 03:18:16 2020 +0000 @@ -9,7 +9,7 @@ #include "Food.h" #include <vector> -/** SnakeEngine Class: +/** SnakeEngine: @brief - Engine that controls the mechanics of the snake game @author Joseph Shotton @date May 2020
--- a/main.cpp	Wed May 27 00:59:14 2020 +0000
+++ b/main.cpp	Wed May 27 03:18:16 2020 +0000
@@ -41,13 +41,11 @@
         while(snake.game_state == 1){ //menu 1
             snake.menu1_select(pad, lcd, mag); //run menu 1 controls
             snake.contrast(pad, lcd);  //set contrast with pot2
-            sleep();
         }
     
         while(snake.game_state == 2){ //menu 2
             snake.menu2_select(pad, lcd, mag); //run menu 2 controls
             snake.contrast(pad, lcd);  //set contrast with pot2
-            sleep(); //puts the chip in 'sleep' mode so it saves power when inactive
         }
     
         while(snake.game_state == 3){ //game
@@ -60,7 +58,6 @@
         while(snake.game_state == 4){ //death menu
             snake.death_select(pad, lcd, mag); //run death menu controls
             snake.contrast(pad, lcd);  //set contrast with pot2
-            sleep(); //puts the chip in 'sleep' mode so it saves power when inactive
         }
     }
 }
\ No newline at end of file