Snake game food library
Revision 2:679ab99f2c0f, committed 2019-04-26
- Comitter:
- 1012754868
- Date:
- Fri Apr 26 04:46:35 2019 +0000
- Parent:
- 1:8d4639c9d1b0
- Commit message:
- Completed the basic function of the game snake, made the game selection interface, and left the highest historical record of the game undone.
Changed in this revision
Food.cpp | Show annotated file Show diff for this revision Revisions of this file |
Food.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 8d4639c9d1b0 -r 679ab99f2c0f Food.cpp --- a/Food.cpp Fri May 05 15:19:10 2017 +0000 +++ b/Food.cpp Fri Apr 26 04:46:35 2019 +0000 @@ -1,6 +1,6 @@ #include "Food.h" -posXY food; +Foodpos food; Food::Food(){ @@ -15,13 +15,13 @@ food.y=25; }//end of init -void Food::draw(N5110 &lcd){ +void Food::drawfood(N5110 &lcd){ lcd.setPixel(food.x,food.y);//draw food }//end of draw -void Food::respawn(){ +void Food::createfood(){ srand(time(NULL));//randomly respawn food food.x=(rand()%81)+2; @@ -29,9 +29,9 @@ }//end of respawn -posXY Food::returnPos(){ +Foodpos Food::returnPos(){ - posXY p = { food.x, food.y}; + Foodpos p = { food.x, food.y}; return p; } \ No newline at end of file
diff -r 8d4639c9d1b0 -r 679ab99f2c0f Food.h --- a/Food.h Fri May 05 15:19:10 2017 +0000 +++ b/Food.h Fri Apr 26 04:46:35 2019 +0000 @@ -8,7 +8,7 @@ //#include "Snake.h" /************************Structs************************/ -struct posXY{ +struct Foodpos{ int x; int y; @@ -23,9 +23,9 @@ Food(); ~Food(); void init(); - void draw(N5110 &lcd); - void respawn(); - posXY returnPos(); + void drawfood(N5110 &lcd); + void createfood(); + Foodpos returnPos(); /************************Private Vars************************/ private: