![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
1
Dependencies: mbed Gamepad N5110
Snake/Snake.h
- Committer:
- 1012754868
- Date:
- 2019-05-02
- Revision:
- 4:c30fb57e0d42
- Parent:
- 3:7b28047013d2
- Child:
- 5:c5fa3fea1a20
File content as of revision 4:c30fb57e0d42:
#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]; char _y[4000]; char _dirc[4000]; }; /************************Class Def************************/ class Snake{ public: /** Constructor */ Snake(); /** Destructor */ ~Snake(); /** 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; float waitTime; float waitExpect; int _speed; int Highest_score; /************************Private Vars************************/ private: int _direction; int initx; int inity; int initl; int x; Direction d; Food _food; }; #endif