Peng Jingran / Mbed 2 deprecated Snake_copy

Dependencies:   mbed FXOS8700Q

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Food.cpp Source File

Food.cpp

00001 #include "Food.h"
00002 
00003 pos food;
00004 
00005 
00006 Food::Food(){
00007     
00008 }
00009     
00010 Food::~Food(){
00011 
00012 }
00013 void Food::init(){
00014         
00015         food.x=7;
00016         food.y=30;
00017 }//set the initial foof position
00018     
00019 void Food::draw(N5110 &lcd){
00020         
00021         lcd.setPixel(food.x,food.y);
00022             
00023 }//draw the food on the screen
00024     
00025 void Food::response(){
00026         
00027         srand(time(NULL));
00028         food.x=(rand()%35)+5; 
00029         food.y=(rand()%28)+3;
00030 }
00031 
00032 pos Food::returnPos(){
00033     
00034         pos a = { food.x, food.y};
00035         return a;   
00036         
00037 }//report position of food