Li Saiwen 201089052
Dependencies: mbed Gamepad N5110
Diff: Food/Food.cpp
- Revision:
- 3:7b28047013d2
- Child:
- 7:cafa0b96e8d3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Food/Food.cpp Thu May 02 06:20:20 2019 +0000 @@ -0,0 +1,37 @@ +#include "Food.h" + +Foodpos food; + + +Food::Food(){ + +} + +Food::~Food(){ + +} +void Food::init(){ + food.x=48;//set first food + food.y=25; +}//end of init + +void Food::drawfood(N5110 &lcd){ + + lcd.setPixel(food.x,food.y);//draw food + +}//end of draw + +void Food::createfood(){ + + srand(time(NULL));//randomly respawn food + food.x=(rand()%81)+2; + food.y=(rand()%27)+10; + +}//end of respawn + +Foodpos Food::returnPos(){ + + Foodpos p = { food.x, food.y}; + return p; + +} \ No newline at end of file