Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed ll16j23s_test_docs
Diff: Food/Food.cpp
- Revision:
- 8:bcc3403d7e79
- Parent:
- 7:dd84e0fab346
- Child:
- 9:0571880085cc
--- 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);
}