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
Diff: Food/Food.cpp
- Revision:
- 7:24a3f13ce36d
- Parent:
- 6:266fb8fc17f4
- Child:
- 9:f3259d652208
--- a/Food/Food.cpp Thu May 28 22:56:46 2020 +0000
+++ b/Food/Food.cpp Sun May 31 14:12:45 2020 +0000
@@ -7,15 +7,20 @@
void Food::init(){
srand(time(NULL));
-_foodx = (rand() % (WIDTH ));
-_foody = (rand() % (HEIGHT ));
+_foodx = (rand() % (WIDTH-3)+1);
+_foody = (rand() % (HEIGHT-3)+1);
}
void Food::draw(N5110 &lcd){
lcd.drawRect(_foodx, _foody, 2, 2, FILL_BLACK);
}
- Vector2D Food::get_f()
+ Vector2D Food::get_pos()
{
Vector2D f = {_foodx,_foody};
- return f;}
\ No newline at end of file
+ return f;}
+
+ void Food::set_pos(Vector2D fp){
+ _foodx = fp.x;
+ _foody = fp.y;
+}
\ No newline at end of file