Joe Shotton / Mbed 2 deprecated ELEC2645_Project_ll16j23s

Dependencies:   mbed ll16j23s_test_docs

Revision:
8:bcc3403d7e79
Parent:
7:dd84e0fab346
Child:
9:0571880085cc
diff -r dd84e0fab346 -r bcc3403d7e79 Food/Food.cpp
--- a/Food/Food.cpp	Sun May 24 22:18:55 2020 +0000
+++ b/Food/Food.cpp	Mon May 25 14:45:32 2020 +0000
@@ -22,14 +22,19 @@
 }
 
 
-void Food::rand_pos(Gamepad &pad) {
-    
+bool Food::rand_pos(Gamepad &pad, N5110 &lcd) {
+    wait_ms(10);
+    pad.led(3,0.1);
     _x = 2 * (rand() % 42); //selects random x cell 
     //printf("Food x: %d\n", _x);
     _y = 2 * (rand() % 24); //selects random y call
     //printf("Food y: %d\n", _y);
+    if (lcd.getPixel(_x,_y)) { //checks if selected pixel is already on (ie body or walls at this location)
+        return false;
+    } else {
+        return true;
+    } 
     
-     pad.led(3,0.1);
     
 }