![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
1
Dependencies: mbed Gamepad N5110
Snake/Snake.h@4:c30fb57e0d42, 2019-05-02 (annotated)
- Committer:
- 1012754868
- Date:
- Thu May 02 07:31:21 2019 +0000
- Revision:
- 4:c30fb57e0d42
- Parent:
- 3:7b28047013d2
- Child:
- 5:c5fa3fea1a20
add doxygen command
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
1012754868 | 3:7b28047013d2 | 1 | #ifndef SNAKE_H |
1012754868 | 3:7b28047013d2 | 2 | #define SNAKE_H |
1012754868 | 3:7b28047013d2 | 3 | |
1012754868 | 3:7b28047013d2 | 4 | #include "mbed.h" |
1012754868 | 3:7b28047013d2 | 5 | #include "N5110.h" |
1012754868 | 3:7b28047013d2 | 6 | #include "Gamepad.h" |
1012754868 | 3:7b28047013d2 | 7 | #include "Food.h" |
1012754868 | 4:c30fb57e0d42 | 8 | |
1012754868 | 4:c30fb57e0d42 | 9 | /** My Snake Class |
1012754868 | 4:c30fb57e0d42 | 10 | * @brief Class for defining snake's properties and states |
1012754868 | 4:c30fb57e0d42 | 11 | * @author Li Saiwen |
1012754868 | 4:c30fb57e0d42 | 12 | * @date May, 2019 |
1012754868 | 4:c30fb57e0d42 | 13 | */ |
1012754868 | 3:7b28047013d2 | 14 | /************************Structs************************/ |
1012754868 | 3:7b28047013d2 | 15 | struct snakePart{ |
1012754868 | 3:7b28047013d2 | 16 | char _x[4000]; |
1012754868 | 3:7b28047013d2 | 17 | char _y[4000]; |
1012754868 | 3:7b28047013d2 | 18 | char _dirc[4000]; |
1012754868 | 3:7b28047013d2 | 19 | |
1012754868 | 3:7b28047013d2 | 20 | }; |
1012754868 | 3:7b28047013d2 | 21 | |
1012754868 | 3:7b28047013d2 | 22 | /************************Class Def************************/ |
1012754868 | 4:c30fb57e0d42 | 23 | class Snake{ |
1012754868 | 3:7b28047013d2 | 24 | |
1012754868 | 3:7b28047013d2 | 25 | public: |
1012754868 | 3:7b28047013d2 | 26 | |
1012754868 | 4:c30fb57e0d42 | 27 | /** Constructor */ |
1012754868 | 3:7b28047013d2 | 28 | Snake(); |
1012754868 | 4:c30fb57e0d42 | 29 | |
1012754868 | 4:c30fb57e0d42 | 30 | /** Destructor */ |
1012754868 | 3:7b28047013d2 | 31 | ~Snake(); |
1012754868 | 4:c30fb57e0d42 | 32 | |
1012754868 | 4:c30fb57e0d42 | 33 | /** initial snake's property |
1012754868 | 4:c30fb57e0d42 | 34 | * @param the value of the initial cooridnate_x(int), coordinate_y(int), length(int), live(int) |
1012754868 | 4:c30fb57e0d42 | 35 | */ |
1012754868 | 4:c30fb57e0d42 | 36 | void init(int x, int y, int length,int _live); |
1012754868 | 4:c30fb57e0d42 | 37 | |
1012754868 | 4:c30fb57e0d42 | 38 | /** draw snake |
1012754868 | 4:c30fb57e0d42 | 39 | * @param the subclass of N5110(lcd) and Gamepad(pad) |
1012754868 | 4:c30fb57e0d42 | 40 | */ |
1012754868 | 3:7b28047013d2 | 41 | void drawsnake(N5110 &lcd, Gamepad &pad); |
1012754868 | 4:c30fb57e0d42 | 42 | |
1012754868 | 4:c30fb57e0d42 | 43 | /** Determine the movement of snake |
1012754868 | 4:c30fb57e0d42 | 44 | * @param the subclass of Gamepad(pad) |
1012754868 | 4:c30fb57e0d42 | 45 | */ |
1012754868 | 3:7b28047013d2 | 46 | void snakemov(Gamepad &pad); |
1012754868 | 4:c30fb57e0d42 | 47 | |
1012754868 | 4:c30fb57e0d42 | 48 | /** Determine if the snake is dead |
1012754868 | 4:c30fb57e0d42 | 49 | * @param the subclass of N5110(lcd) and Gamepad(pad) |
1012754868 | 4:c30fb57e0d42 | 50 | */ |
1012754868 | 3:7b28047013d2 | 51 | int dead(N5110 &lcd, Gamepad &pad); |
1012754868 | 4:c30fb57e0d42 | 52 | |
1012754868 | 4:c30fb57e0d42 | 53 | /** Determine if the snake eats food |
1012754868 | 4:c30fb57e0d42 | 54 | * @param the subclass of Gamepad(pad) |
1012754868 | 4:c30fb57e0d42 | 55 | * @return return 0 |
1012754868 | 4:c30fb57e0d42 | 56 | */ |
1012754868 | 3:7b28047013d2 | 57 | void eat(Gamepad &pad); |
1012754868 | 4:c30fb57e0d42 | 58 | |
1012754868 | 4:c30fb57e0d42 | 59 | /** Determine if the snake collide the wall |
1012754868 | 4:c30fb57e0d42 | 60 | * @param the subclass of N5110(lcd) and Gamepad(pad) |
1012754868 | 4:c30fb57e0d42 | 61 | */ |
1012754868 | 3:7b28047013d2 | 62 | void check_WallCollision(N5110 &lcd, Gamepad &pad); |
1012754868 | 4:c30fb57e0d42 | 63 | |
1012754868 | 4:c30fb57e0d42 | 64 | /** Determine if the snake collide the tail |
1012754868 | 4:c30fb57e0d42 | 65 | * @param the subclass of N5110(lcd) and Gamepad(pad) |
1012754868 | 4:c30fb57e0d42 | 66 | */ |
1012754868 | 3:7b28047013d2 | 67 | void check_TailCollision(N5110 &lcd, Gamepad &pad); |
1012754868 | 4:c30fb57e0d42 | 68 | |
1012754868 | 4:c30fb57e0d42 | 69 | /** Draw the current health points and score |
1012754868 | 4:c30fb57e0d42 | 70 | * @param the subclass of N5110(lcd) |
1012754868 | 4:c30fb57e0d42 | 71 | */ |
1012754868 | 3:7b28047013d2 | 72 | void drawscore(N5110 &lcd); |
1012754868 | 4:c30fb57e0d42 | 73 | |
1012754868 | 4:c30fb57e0d42 | 74 | /** Make a noise when eating food |
1012754868 | 4:c30fb57e0d42 | 75 | * @param the subclass of Gamepad(pad) |
1012754868 | 4:c30fb57e0d42 | 76 | */ |
1012754868 | 3:7b28047013d2 | 77 | void Tone_1(Gamepad &pad); |
1012754868 | 4:c30fb57e0d42 | 78 | |
1012754868 | 4:c30fb57e0d42 | 79 | /** Make a noise when collide wall |
1012754868 | 4:c30fb57e0d42 | 80 | * @param the subclass of Gamepad(pad) |
1012754868 | 4:c30fb57e0d42 | 81 | */ |
1012754868 | 3:7b28047013d2 | 82 | void game_music(Gamepad &pad); |
1012754868 | 3:7b28047013d2 | 83 | int _length; |
1012754868 | 3:7b28047013d2 | 84 | int live; |
1012754868 | 3:7b28047013d2 | 85 | float waitTime; |
1012754868 | 3:7b28047013d2 | 86 | float waitExpect; |
1012754868 | 3:7b28047013d2 | 87 | int _speed; |
1012754868 | 3:7b28047013d2 | 88 | int Highest_score; |
1012754868 | 3:7b28047013d2 | 89 | |
1012754868 | 3:7b28047013d2 | 90 | |
1012754868 | 3:7b28047013d2 | 91 | |
1012754868 | 3:7b28047013d2 | 92 | /************************Private Vars************************/ |
1012754868 | 3:7b28047013d2 | 93 | private: |
1012754868 | 3:7b28047013d2 | 94 | |
1012754868 | 3:7b28047013d2 | 95 | int _direction; |
1012754868 | 3:7b28047013d2 | 96 | int initx; |
1012754868 | 3:7b28047013d2 | 97 | int inity; |
1012754868 | 3:7b28047013d2 | 98 | int initl; |
1012754868 | 3:7b28047013d2 | 99 | int x; |
1012754868 | 3:7b28047013d2 | 100 | Direction d; |
1012754868 | 3:7b28047013d2 | 101 | Food _food; |
1012754868 | 3:7b28047013d2 | 102 | |
1012754868 | 3:7b28047013d2 | 103 | |
1012754868 | 3:7b28047013d2 | 104 | }; |
1012754868 | 3:7b28047013d2 | 105 | |
1012754868 | 3:7b28047013d2 | 106 | #endif |