Owen Cavender 201159294

Dependencies:   mbed Gamepad2

Revision:
13:b37dde18bfdc
Parent:
12:60c856354406
Child:
14:7fb3c93343b6
--- a/snake.cpp	Fri May 29 16:00:56 2020 +0000
+++ b/snake.cpp	Fri May 29 16:27:29 2020 +0000
@@ -60,7 +60,7 @@
         //   _countdown = _reset_value;
         _score++;
         _reset_apple = true;
-        _countdown =10;          //causes new apple position to be generated
+        _countdown = 30;          //causes new apple position to be generated
         pad.tone(1500.0,0.5);
         pad.led(2, 1);
         pad.led(4, 1);
@@ -119,13 +119,13 @@
             lcd.printString(" ~.~.~.~.<8>~  ", 0, 5);
 
         }
-
+            lcd.refresh();
     }
 }
 
 void Snake::render(N5110 &lcd)
 {
-    lcd.refresh();
+
 
     //apple
     lcd.setPixel(_apx, _apy,1);                        //apple
@@ -187,7 +187,7 @@
 void Snake::move_snake()
 {
     if (_direction == up) {
-        _x5 = _x5; 
+        _x5 = _x4; 
         _x4 = _x3;      
         _x3 = _x2;
         _y3 = _y2;
@@ -214,7 +214,8 @@
 
     }
     if (_direction == left) {
-
+        _x5 = _x4;
+        _y5 = _y4;
         _x3 = _x2;
         _y3 = _y2;
         _x2 = _x1;
@@ -230,6 +231,8 @@
     }
 
     if (_direction == right) {
+        _x5 = _x4;
+        _y5 = _y4;
         _x3 = _x2;
         _y3 = _y2;
         _x2 = _x1;