Owen Cavender 201159294

Dependencies:   mbed Gamepad2

Revision:
5:d716013c6a18
Parent:
2:44e4a6ecdbef
--- a/GameEngine.cpp	Tue May 26 18:42:16 2020 +0000
+++ b/GameEngine.cpp	Wed May 27 10:27:34 2020 +0000
@@ -29,7 +29,9 @@
 
 Vector2D GameEngine::get_Snakehead()
 {
-    Vector2D Snakehead = {_shx, _shy};
+    Vector2D Snakehead;
+    Snakehead.x = _shx;
+    Snakehead.y = _shy;
     return Snakehead;
 }
 
@@ -50,19 +52,18 @@
 {
 
     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?
+    int appleposy = rand()%48;             //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 -- 'if it is already filled on lcd, pick new position'
+    if(lcd.getPixel(appleposx, appleposy)==1) {      // 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
+        appleposy = rand()%48;   //  making sure the apple doesnt spawn inside the snakes body or wall which would increase the score
     } else {
 
 
         _apx = appleposx;                 //i and j are fed into applepos.x/y -- those values are then fed into set_applepos which assigngs that value to _appleposx/y which then is fed into get_applepos where it is stored and returned
         _apy = appleposy;      //alters value of private variable - this can then be accessed by get_Applepos
 
-        lcd.setPixel(_apx,_apy, true);
     }
 }