Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Revision:
77:5c6bd659c32d
Parent:
63:205f0ca48473
Child:
81:4c1641e10dcd
--- a/GameObjects/SnakeFood/SnakeFood.cpp	Sun May 05 15:00:34 2019 +0000
+++ b/GameObjects/SnakeFood/SnakeFood.cpp	Sun May 05 16:02:24 2019 +0000
@@ -25,17 +25,11 @@
 
 void SnakeFood::draw(N5110 &lcd)
 {
-
     velocity.x = 0;
     velocity.y = 1;
-
     //add sideways velocity incase I want to make it dodgy.
 
     //Resets SnakeFood position if it reaches the bottom of the screen.
-
-    if(_fy >= 48) {
-        n = 0;
-    }
     if(n == 0) {
         _fx = (rand() % 82);  //this makes the food pop up at a random, unspecified location in the x axis.
         _fy = -3;
@@ -56,6 +50,10 @@
 
 void SnakeFood::update()
 {
+    //uses draw() to reset snake position after snake has gone past the screen.
+    if(_fy >= 48) {
+        n = 0;
+    }
     _fx += velocity.x;
     _fy += velocity.y;
 }