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
Food/Food.cpp@6:266fb8fc17f4, 2020-05-28 (annotated)
- Committer:
- el18lg
- Date:
- Thu May 28 22:56:46 2020 +0000
- Revision:
- 6:266fb8fc17f4
- Parent:
- 1:bdafa20e71a0
- Child:
- 7:24a3f13ce36d
Snake body now follows the head of my snake;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| el18lg | 6:266fb8fc17f4 | 1 | #include "Food.h" |
| el18lg | 6:266fb8fc17f4 | 2 | |
| el18lg | 6:266fb8fc17f4 | 3 | Food::Food() { |
| el18lg | 6:266fb8fc17f4 | 4 | } |
| el18lg | 6:266fb8fc17f4 | 5 | Food::~Food() { |
| el18lg | 6:266fb8fc17f4 | 6 | } |
| el18lg | 6:266fb8fc17f4 | 7 | void Food::init(){ |
| el18lg | 6:266fb8fc17f4 | 8 | srand(time(NULL)); |
| el18lg | 6:266fb8fc17f4 | 9 | |
| el18lg | 6:266fb8fc17f4 | 10 | _foodx = (rand() % (WIDTH )); |
| el18lg | 6:266fb8fc17f4 | 11 | _foody = (rand() % (HEIGHT )); |
| el18lg | 6:266fb8fc17f4 | 12 | } |
| el18lg | 6:266fb8fc17f4 | 13 | |
| el18lg | 6:266fb8fc17f4 | 14 | void Food::draw(N5110 &lcd){ |
| el18lg | 6:266fb8fc17f4 | 15 | lcd.drawRect(_foodx, _foody, 2, 2, FILL_BLACK); |
| el18lg | 6:266fb8fc17f4 | 16 | } |
| el18lg | 6:266fb8fc17f4 | 17 | |
| el18lg | 6:266fb8fc17f4 | 18 | Vector2D Food::get_f() |
| el18lg | 6:266fb8fc17f4 | 19 | { |
| el18lg | 6:266fb8fc17f4 | 20 | Vector2D f = {_foodx,_foody}; |
| el18lg | 6:266fb8fc17f4 | 21 | return f;} |