XJEL2645 (18/19)
/
Snake_Project
Du Xianjie 201089059
Diff: Food/Food.cpp
- Revision:
- 0:bc1d36f5f772
- Child:
- 13:9a6aff771774
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Food/Food.cpp Sun May 05 14:06:00 2019 +0000 @@ -0,0 +1,37 @@ +#include "Food.h" + +pos food; + + +Food::Food(){ + +} + +Food::~Food(){ + +} +void Food::init(){ + + food.x=30; + food.y=30; +}//set the initial foof position + +void Food::draw(N5110 &lcd){ + + lcd.setPixel(food.x,food.y); + +}//draw the food on the screen + +void Food::response(){ + + srand(time(NULL)); + food.x=(rand()%35)+5; + food.y=(rand()%28)+3; +} + +pos Food::returnPos(){ + + pos a = { food.x, food.y}; + return a; + +}//report food position