ZIYI CHEN ml17z4c 201214999
Dependencies: mbed
Game/Game.h@13:08bdb4cffacd, 2019-05-09 (annotated)
- Committer:
- ziyi11
- Date:
- Thu May 09 14:36:47 2019 +0000
- Revision:
- 13:08bdb4cffacd
- Child:
- 14:60c31d25d895
try;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ziyi11 | 13:08bdb4cffacd | 1 | #include "mbed.h" |
ziyi11 | 13:08bdb4cffacd | 2 | #include "N5110.h" |
ziyi11 | 13:08bdb4cffacd | 3 | #include "Gamepad.h" |
ziyi11 | 13:08bdb4cffacd | 4 | |
ziyi11 | 13:08bdb4cffacd | 5 | |
ziyi11 | 13:08bdb4cffacd | 6 | /** The Game class |
ziyi11 | 13:08bdb4cffacd | 7 | * @brief the functions of game roles |
ziyi11 | 13:08bdb4cffacd | 8 | * @author ZIYI CHEN |
ziyi11 | 13:08bdb4cffacd | 9 | * @date may 2019 |
ziyi11 | 13:08bdb4cffacd | 10 | */ |
ziyi11 | 13:08bdb4cffacd | 11 | |
ziyi11 | 13:08bdb4cffacd | 12 | class Game |
ziyi11 | 13:08bdb4cffacd | 13 | { |
ziyi11 | 13:08bdb4cffacd | 14 | public: |
ziyi11 | 13:08bdb4cffacd | 15 | |
ziyi11 | 13:08bdb4cffacd | 16 | /**Constructor*/ |
ziyi11 | 13:08bdb4cffacd | 17 | Game(); |
ziyi11 | 13:08bdb4cffacd | 18 | |
ziyi11 | 13:08bdb4cffacd | 19 | /**Destructor*/ |
ziyi11 | 13:08bdb4cffacd | 20 | ~Game(); |
ziyi11 | 13:08bdb4cffacd | 21 | |
ziyi11 | 13:08bdb4cffacd | 22 | /** init function |
ziyi11 | 13:08bdb4cffacd | 23 | * @param inital starting coordinate of snake head. |
ziyi11 | 13:08bdb4cffacd | 24 | */ |
ziyi11 | 13:08bdb4cffacd | 25 | void init(int x, int y); |
ziyi11 | 13:08bdb4cffacd | 26 | /** Updates coordinate of snake |
ziyi11 | 13:08bdb4cffacd | 27 | * @param the joystick'direction |
ziyi11 | 13:08bdb4cffacd | 28 | */ |
ziyi11 | 13:08bdb4cffacd | 29 | void update(Direction d); |
ziyi11 | 13:08bdb4cffacd | 30 | |
ziyi11 | 13:08bdb4cffacd | 31 | /** Gets snake length |
ziyi11 | 13:08bdb4cffacd | 32 | * @return the value of snake length |
ziyi11 | 13:08bdb4cffacd | 33 | */ |
ziyi11 | 13:08bdb4cffacd | 34 | int getLength(); |
ziyi11 | 13:08bdb4cffacd | 35 | |
ziyi11 | 13:08bdb4cffacd | 36 | /** add snake length by 1 */ |
ziyi11 | 13:08bdb4cffacd | 37 | void grow(); |
ziyi11 | 13:08bdb4cffacd | 38 | |
ziyi11 | 13:08bdb4cffacd | 39 | |
ziyi11 | 13:08bdb4cffacd | 40 | /** Gets x coordinate of the snake |
ziyi11 | 13:08bdb4cffacd | 41 | * @param the position of snake in x coorinate |
ziyi11 | 13:08bdb4cffacd | 42 | * @return value of _x[now] |
ziyi11 | 13:08bdb4cffacd | 43 | */ |
ziyi11 | 13:08bdb4cffacd | 44 | int xcoordinate(int now); |
ziyi11 | 13:08bdb4cffacd | 45 | |
ziyi11 | 13:08bdb4cffacd | 46 | /** Gets y coordinate of the snake |
ziyi11 | 13:08bdb4cffacd | 47 | * @param the position of snake in y coorinate |
ziyi11 | 13:08bdb4cffacd | 48 | * @return value of _y[now] |
ziyi11 | 13:08bdb4cffacd | 49 | */ |
ziyi11 | 13:08bdb4cffacd | 50 | int ycoordinate(int now); |
ziyi11 | 13:08bdb4cffacd | 51 | /** the previous direction of snake*/ |
ziyi11 | 13:08bdb4cffacd | 52 | char Previous_direction; |
ziyi11 | 13:08bdb4cffacd | 53 | |
ziyi11 | 13:08bdb4cffacd | 54 | |
ziyi11 | 13:08bdb4cffacd | 55 | int _length; |
ziyi11 | 13:08bdb4cffacd | 56 | |
ziyi11 | 13:08bdb4cffacd | 57 | |
ziyi11 | 13:08bdb4cffacd | 58 | |
ziyi11 | 13:08bdb4cffacd | 59 | /**the _y and _y array*/ |
ziyi11 | 13:08bdb4cffacd | 60 | int _x[4032]; |
ziyi11 | 13:08bdb4cffacd | 61 | int _y[4032]; |
ziyi11 | 13:08bdb4cffacd | 62 | |
ziyi11 | 13:08bdb4cffacd | 63 | |
ziyi11 | 13:08bdb4cffacd | 64 | |
ziyi11 | 13:08bdb4cffacd | 65 | }; |