1
Dependencies: mbed Gamepad N5110
Snake/Snake.h
- Committer:
- 1012754868
- Date:
- 2019-05-05
- Revision:
- 9:5f73221012bf
- Parent:
- 7:cafa0b96e8d3
- Child:
- 10:7cb79dbb351a
File content as of revision 9:5f73221012bf:
#ifndef SNAKE_H #define SNAKE_H #include "mbed.h" #include "N5110.h" #include "Gamepad.h" #include "Food.h" /**snakePart struct */ struct snakePart{ char _x[4000];/**< Arrays to store snake X coordinate*/ char _y[4000];/**< Arrays to store snake y coordinate*/ char _dirc[4000];/**< Arrays to store snake direction*/ }; /** My Snake Class * @brief Class for defining snake's properties and states * @author Li Saiwen * @date May, 2019 */ class Snake{ public: /** Constructor */ Snake(); /** Destructor */ ~Snake(); /** initial snake's property * @param the value of the initial cooridnate_x(int) of snake tail * @param the value of the initial coordinate_y(int) of snake tail * @param the value of the initial length(int) of snake * @param the value of the initial live(int) of snake */ void init(int x, int y, int length,int _live); /** draw snake on the map * @param the subclass of N5110(lcd) * @param the subclass of Gamepad(pad) */ void drawsnake(N5110 &lcd, Gamepad &pad); /** Determine the movement direction of snake * @param the subclass of Gamepad(pad) */ void snakemov(Gamepad &pad); /** Determine if the snake is dead * @param the subclass of N5110(lcd) * @param the subclass of Gamepad(pad) * @return return 0 to end loop */ int dead(N5110 &lcd, Gamepad &pad); /** Determine if the snake eats food * @param the subclass of Gamepad(pad) */ void eat(Gamepad &pad); /** Determine if the snake collide the wall * @param the subclass of N5110(lcd) * @param the subclass of Gamepad(pad) */ void check_WallCollision(N5110 &lcd, Gamepad &pad); /** Determine if the snake collide the tail * @param the subclass of N5110(lcd) * @param the subclass of 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; float waitTime; float waitExpect; int _speed; int Highest_score; private: int _direction; int initx; int inity; int initl; int x; Direction d; Food _food; }; #endif