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
Food/Food.cpp
- Committer:
- JoeShotton
- Date:
- 2020-05-20
- Revision:
- 3:fcd6d70e9694
- Child:
- 4:ea3fa51c4386
File content as of revision 3:fcd6d70e9694:
#include "Food.h"
Food::Food()
{
//constructor
}
Food::~Food()
{
//deconstructor
}
void Food::init()
{
_x = 84; // starts off-screen
_y = 0;
//srand (x); //CHANGE THIS TO ACCELERAOMETRE VALUE
}
Vector2D Food::rand_pos(int cell_size) {
int _x = cell_size * (rand() % 42); //selects random x cell
printf("Food x: %d\n", _x);
int _y = cell_size * (rand() % 24); //selects random y call
printf("Food y: %d\n", _y);
Vector2D pos = {_x,_y};
return pos;
}
void Food::draw(N5110 &lcd, int frame)
{
// draw food, with alternate locations depending on frame.
lcd.drawLine(_x + frame, _y, _x + 1 - frame,_y + 1,1);
}