ZIYI CHEN ml17z4c 201214999

Dependencies:   mbed

Committer:
ziyi11
Date:
Mon May 06 00:06:15 2019 +0000
Revision:
8:52e0506e98b8
Parent:
7:8b6f175fcb0e
Child:
9:a8b2086a46e5
add game.h and game.cpp although it still has some errors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ziyi11 7:8b6f175fcb0e 1 #include "Food.h"
ziyi11 7:8b6f175fcb0e 2
ziyi11 7:8b6f175fcb0e 3 // nothing doing in the constructor and destructor
ziyi11 7:8b6f175fcb0e 4 Food::Food()
ziyi11 7:8b6f175fcb0e 5 {
ziyi11 7:8b6f175fcb0e 6
ziyi11 7:8b6f175fcb0e 7 }
ziyi11 7:8b6f175fcb0e 8
ziyi11 7:8b6f175fcb0e 9 Food::~Food()
ziyi11 7:8b6f175fcb0e 10 {
ziyi11 7:8b6f175fcb0e 11
ziyi11 7:8b6f175fcb0e 12 }
ziyi11 7:8b6f175fcb0e 13
ziyi11 7:8b6f175fcb0e 14 //No major comments are needed as all fucntions are simple and self explanatory
ziyi11 7:8b6f175fcb0e 15
ziyi11 7:8b6f175fcb0e 16 void Food::init(int x, int y)
ziyi11 7:8b6f175fcb0e 17 {
ziyi11 7:8b6f175fcb0e 18 _x = x;
ziyi11 7:8b6f175fcb0e 19 _y = y;
ziyi11 7:8b6f175fcb0e 20
ziyi11 8:52e0506e98b8 21 printf("Food init\n");
ziyi11 7:8b6f175fcb0e 22 }
ziyi11 7:8b6f175fcb0e 23
ziyi11 8:52e0506e98b8 24
ziyi11 7:8b6f175fcb0e 25 int Food::getX()
ziyi11 7:8b6f175fcb0e 26 {
ziyi11 7:8b6f175fcb0e 27 return _x;
ziyi11 7:8b6f175fcb0e 28 }
ziyi11 7:8b6f175fcb0e 29
ziyi11 7:8b6f175fcb0e 30 int Food::getY()
ziyi11 7:8b6f175fcb0e 31 {
ziyi11 7:8b6f175fcb0e 32 return _y;
ziyi11 7:8b6f175fcb0e 33 }
ziyi11 7:8b6f175fcb0e 34 void Food::random()
ziyi11 7:8b6f175fcb0e 35 {
ziyi11 7:8b6f175fcb0e 36 _x = rand() % 48; //randomly generates a number between 0 and 21
ziyi11 7:8b6f175fcb0e 37 _y = rand() % 84;
ziyi11 8:52e0506e98b8 38 }