ZIYI CHEN ml17z4c 201214999
Dependencies: mbed
Food/Food.h@7:8b6f175fcb0e, 2019-04-30 (annotated)
- Committer:
- ziyi11
- Date:
- Tue Apr 30 09:14:17 2019 +0000
- Revision:
- 7:8b6f175fcb0e
- Child:
- 8:52e0506e98b8
add food and menu;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ziyi11 | 7:8b6f175fcb0e | 1 | #include "mbed.h" |
ziyi11 | 7:8b6f175fcb0e | 2 | #include "N5110.h" |
ziyi11 | 7:8b6f175fcb0e | 3 | #include "Gamepad.h" |
ziyi11 | 7:8b6f175fcb0e | 4 | |
ziyi11 | 7:8b6f175fcb0e | 5 | |
ziyi11 | 7:8b6f175fcb0e | 6 | /** The Food class |
ziyi11 | 7:8b6f175fcb0e | 7 | * @brief generate a position of the food for snake |
ziyi11 | 7:8b6f175fcb0e | 8 | * @author ZiYi Chen |
ziyi11 | 7:8b6f175fcb0e | 9 | * @date May, 2019 |
ziyi11 | 7:8b6f175fcb0e | 10 | */ |
ziyi11 | 7:8b6f175fcb0e | 11 | |
ziyi11 | 7:8b6f175fcb0e | 12 | class Food |
ziyi11 | 7:8b6f175fcb0e | 13 | { |
ziyi11 | 7:8b6f175fcb0e | 14 | public: |
ziyi11 | 7:8b6f175fcb0e | 15 | |
ziyi11 | 7:8b6f175fcb0e | 16 | /** Constructor */ |
ziyi11 | 7:8b6f175fcb0e | 17 | Food(); |
ziyi11 | 7:8b6f175fcb0e | 18 | |
ziyi11 | 7:8b6f175fcb0e | 19 | /** Destructor */ |
ziyi11 | 7:8b6f175fcb0e | 20 | ~Food(); |
ziyi11 | 7:8b6f175fcb0e | 21 | |
ziyi11 | 7:8b6f175fcb0e | 22 | /** Initialisation function |
ziyi11 | 7:8b6f175fcb0e | 23 | * @param the inital starting position for the food, given in X and Y (int) |
ziyi11 | 7:8b6f175fcb0e | 24 | */ |
ziyi11 | 7:8b6f175fcb0e | 25 | void init(int x, int y); |
ziyi11 | 7:8b6f175fcb0e | 26 | |
ziyi11 | 7:8b6f175fcb0e | 27 | /** Gets the current X coordinate of the food |
ziyi11 | 7:8b6f175fcb0e | 28 | * @return the current X coordinate |
ziyi11 | 7:8b6f175fcb0e | 29 | */ |
ziyi11 | 7:8b6f175fcb0e | 30 | int getX(); |
ziyi11 | 7:8b6f175fcb0e | 31 | |
ziyi11 | 7:8b6f175fcb0e | 32 | |
ziyi11 | 7:8b6f175fcb0e | 33 | /** Gets the current Y coordinate of the food |
ziyi11 | 7:8b6f175fcb0e | 34 | * @return the current Y coordinate |
ziyi11 | 7:8b6f175fcb0e | 35 | */ |
ziyi11 | 7:8b6f175fcb0e | 36 | int getY(); |
ziyi11 | 7:8b6f175fcb0e | 37 | |
ziyi11 | 7:8b6f175fcb0e | 38 | |
ziyi11 | 7:8b6f175fcb0e | 39 | /** Randomises the current location of the food */ |
ziyi11 | 7:8b6f175fcb0e | 40 | void random(); |
ziyi11 | 7:8b6f175fcb0e | 41 | |
ziyi11 | 7:8b6f175fcb0e | 42 | private: |
ziyi11 | 7:8b6f175fcb0e | 43 | |
ziyi11 | 7:8b6f175fcb0e | 44 | //Private Variables |
ziyi11 | 7:8b6f175fcb0e | 45 | int _x; |
ziyi11 | 7:8b6f175fcb0e | 46 | int _y; |
ziyi11 | 7:8b6f175fcb0e | 47 | }; |