1

Dependencies:   mbed Gamepad N5110

Committer:
1012754868
Date:
Thu May 02 06:20:20 2019 +0000
Revision:
3:7b28047013d2
Child:
7:cafa0b96e8d3
1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
1012754868 3:7b28047013d2 1 #include "Food.h"
1012754868 3:7b28047013d2 2
1012754868 3:7b28047013d2 3 Foodpos food;
1012754868 3:7b28047013d2 4
1012754868 3:7b28047013d2 5
1012754868 3:7b28047013d2 6 Food::Food(){
1012754868 3:7b28047013d2 7
1012754868 3:7b28047013d2 8 }
1012754868 3:7b28047013d2 9
1012754868 3:7b28047013d2 10 Food::~Food(){
1012754868 3:7b28047013d2 11
1012754868 3:7b28047013d2 12 }
1012754868 3:7b28047013d2 13 void Food::init(){
1012754868 3:7b28047013d2 14 food.x=48;//set first food
1012754868 3:7b28047013d2 15 food.y=25;
1012754868 3:7b28047013d2 16 }//end of init
1012754868 3:7b28047013d2 17
1012754868 3:7b28047013d2 18 void Food::drawfood(N5110 &lcd){
1012754868 3:7b28047013d2 19
1012754868 3:7b28047013d2 20 lcd.setPixel(food.x,food.y);//draw food
1012754868 3:7b28047013d2 21
1012754868 3:7b28047013d2 22 }//end of draw
1012754868 3:7b28047013d2 23
1012754868 3:7b28047013d2 24 void Food::createfood(){
1012754868 3:7b28047013d2 25
1012754868 3:7b28047013d2 26 srand(time(NULL));//randomly respawn food
1012754868 3:7b28047013d2 27 food.x=(rand()%81)+2;
1012754868 3:7b28047013d2 28 food.y=(rand()%27)+10;
1012754868 3:7b28047013d2 29
1012754868 3:7b28047013d2 30 }//end of respawn
1012754868 3:7b28047013d2 31
1012754868 3:7b28047013d2 32 Foodpos Food::returnPos(){
1012754868 3:7b28047013d2 33
1012754868 3:7b28047013d2 34 Foodpos p = { food.x, food.y};
1012754868 3:7b28047013d2 35 return p;
1012754868 3:7b28047013d2 36
1012754868 3:7b28047013d2 37 }