![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
1
Dependencies: mbed Gamepad N5110
Diff: Snake/Snake.h
- Revision:
- 4:c30fb57e0d42
- Parent:
- 3:7b28047013d2
- Child:
- 5:c5fa3fea1a20
--- a/Snake/Snake.h Thu May 02 06:20:20 2019 +0000 +++ b/Snake/Snake.h Thu May 02 07:31:21 2019 +0000 @@ -1,11 +1,16 @@ #ifndef SNAKE_H #define SNAKE_H - #include "mbed.h" #include "N5110.h" #include "Gamepad.h" #include "Food.h" + +/** My Snake Class +* @brief Class for defining snake's properties and states +* @author Li Saiwen +* @date May, 2019 +*/ /************************Structs************************/ struct snakePart{ char _x[4000]; @@ -15,23 +20,65 @@ }; /************************Class Def************************/ +class Snake{ -class Snake{ - -/************************Public Vars************************/ public: + /** Constructor */ Snake(); + + /** Destructor */ ~Snake(); - void init(int x, int y, int lenght,int _live); + + /** initial snake's property + * @param the value of the initial cooridnate_x(int), coordinate_y(int), length(int), live(int) + */ + void init(int x, int y, int length,int _live); + + /** draw snake + * @param the subclass of N5110(lcd) and Gamepad(pad) + */ void drawsnake(N5110 &lcd, Gamepad &pad); + + /** Determine the movement of snake + * @param the subclass of Gamepad(pad) + */ void snakemov(Gamepad &pad); + + /** Determine if the snake is dead + * @param the subclass of N5110(lcd) and Gamepad(pad) + */ int dead(N5110 &lcd, Gamepad &pad); + + /** Determine if the snake eats food + * @param the subclass of Gamepad(pad) + * @return return 0 + */ void eat(Gamepad &pad); + + /** Determine if the snake collide the wall + * @param the subclass of N5110(lcd) and Gamepad(pad) + */ void check_WallCollision(N5110 &lcd, Gamepad &pad); + + /** Determine if the snake collide the tail + * @param the subclass of N5110(lcd) and Gamepad(pad) + */ void check_TailCollision(N5110 &lcd, Gamepad &pad); + + /** Draw the current health points and score + * @param the subclass of N5110(lcd) + */ void drawscore(N5110 &lcd); + + /** Make a noise when eating food + * @param the subclass of Gamepad(pad) + */ void Tone_1(Gamepad &pad); + + /** Make a noise when collide wall + * @param the subclass of Gamepad(pad) + */ void game_music(Gamepad &pad); int _length; int live;