Owen Cavender 201159294

Dependencies:   mbed Gamepad2

Revision:
2:44e4a6ecdbef
Parent:
1:897160a1a3ae
--- a/GameEngine.cpp	Tue May 26 12:17:59 2020 +0000
+++ b/GameEngine.cpp	Tue May 26 18:35:44 2020 +0000
@@ -9,12 +9,14 @@
 
 }
 
-void GameEngine::init(int shx, int shy, int apx, int apy)
+void GameEngine::init(int shx, int shy, int apx, int apy, int Oshx, int Oshy)
 {
     _shx = shx;
-    _shy = shy;            //intial value in front of snake
+    _shy = shy;
     _apx = apx;
     _apy = apy;
+    _Oshx = Oshx;
+    _Oshy = Oshy;
 }
 
 
@@ -31,6 +33,11 @@
     return Snakehead;
 }
 
+Vector2D GameEngine::get_oldSnakehead() 
+{
+    Vector2D oldSnakehead = {_Oshx, _Oshy};
+    return oldSnakehead;
+}
 
 Vector2D GameEngine::get_Applepos()
 {
@@ -42,11 +49,11 @@
 void GameEngine::set_Applepos(N5110 &lcd)
 {
 
-    int appleposx = rand()%84;             //is this generating new position or will it just stick to one random selection - need to make sure its in the loop
-    int appleposy = rand()%24;
+    int appleposx = rand()%84;             
+    int appleposy = rand()%24;             //ROB apparently rand() is seeded so will generate same position each time - do you know any other random methods to put here?
 
 
-    if(lcd.getPixel(appleposx, appleposy)) {      // this pixel is set } else {     // this pixel is clear }
+    if(lcd.getPixel(appleposx, appleposy)) {      // this pixel is set -- 'if it is already filled on lcd, pick new position'
         appleposx = rand()%84;
         appleposy = rand()%24;   //  making sure the apple doesnt spawn inside the snakes body or wall which would increase the score
     } else {