1

Dependencies:   mbed Gamepad N5110

Committer:
1012754868
Date:
Sun May 05 12:40:42 2019 +0000
Revision:
10:7cb79dbb351a
Parent:
9:5f73221012bf
update the doxygen

Who changed what in which revision?

UserRevisionLine numberNew 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 9:5f73221012bf 9 /**snakePart struct */
1012754868 3:7b28047013d2 10 struct snakePart{
1012754868 9:5f73221012bf 11 char _x[4000];/**< Arrays to store snake X coordinate*/
1012754868 9:5f73221012bf 12 char _y[4000];/**< Arrays to store snake y coordinate*/
1012754868 9:5f73221012bf 13 char _dirc[4000];/**< Arrays to store snake direction*/
1012754868 3:7b28047013d2 14
1012754868 3:7b28047013d2 15 };
1012754868 3:7b28047013d2 16
1012754868 7:cafa0b96e8d3 17
1012754868 5:c5fa3fea1a20 18
1012754868 5:c5fa3fea1a20 19 /** My Snake Class
1012754868 5:c5fa3fea1a20 20 * @brief Class for defining snake's properties and states
1012754868 5:c5fa3fea1a20 21 * @author Li Saiwen
1012754868 5:c5fa3fea1a20 22 * @date May, 2019
1012754868 5:c5fa3fea1a20 23 */
1012754868 4:c30fb57e0d42 24 class Snake{
1012754868 3:7b28047013d2 25
1012754868 3:7b28047013d2 26 public:
1012754868 3:7b28047013d2 27
1012754868 4:c30fb57e0d42 28 /** Constructor */
1012754868 3:7b28047013d2 29 Snake();
1012754868 4:c30fb57e0d42 30
1012754868 4:c30fb57e0d42 31 /** Destructor */
1012754868 3:7b28047013d2 32 ~Snake();
1012754868 4:c30fb57e0d42 33
1012754868 4:c30fb57e0d42 34 /** initial snake's property
1012754868 10:7cb79dbb351a 35 * @param value of the initial cooridnate_x(int) of snake tail
1012754868 10:7cb79dbb351a 36 * @param value of the initial coordinate_y(int) of snake tail
1012754868 10:7cb79dbb351a 37 * @param value of the initial length(int) of snake
1012754868 10:7cb79dbb351a 38 * @param value of the initial live(int) of snake
1012754868 4:c30fb57e0d42 39 */
1012754868 4:c30fb57e0d42 40 void init(int x, int y, int length,int _live);
1012754868 4:c30fb57e0d42 41
1012754868 9:5f73221012bf 42 /** draw snake on the map
1012754868 10:7cb79dbb351a 43 * @param lcd the subclass of N5110
1012754868 10:7cb79dbb351a 44 * @param pad the subclass of Gamepad
1012754868 4:c30fb57e0d42 45 */
1012754868 3:7b28047013d2 46 void drawsnake(N5110 &lcd, Gamepad &pad);
1012754868 4:c30fb57e0d42 47
1012754868 9:5f73221012bf 48 /** Determine the movement direction of snake
1012754868 10:7cb79dbb351a 49 * @param pad the subclass of Gamepad
1012754868 4:c30fb57e0d42 50 */
1012754868 3:7b28047013d2 51 void snakemov(Gamepad &pad);
1012754868 4:c30fb57e0d42 52
1012754868 4:c30fb57e0d42 53 /** Determine if the snake is dead
1012754868 10:7cb79dbb351a 54 * @param lcd the subclass of N5110
1012754868 10:7cb79dbb351a 55 * @param pad the subclass of Gamepad
1012754868 9:5f73221012bf 56 * @return return 0 to end loop
1012754868 4:c30fb57e0d42 57 */
1012754868 3:7b28047013d2 58 int dead(N5110 &lcd, Gamepad &pad);
1012754868 4:c30fb57e0d42 59
1012754868 4:c30fb57e0d42 60 /** Determine if the snake eats food
1012754868 10:7cb79dbb351a 61 * @param pad the subclass of Gamepad
1012754868 4:c30fb57e0d42 62 */
1012754868 3:7b28047013d2 63 void eat(Gamepad &pad);
1012754868 4:c30fb57e0d42 64
1012754868 4:c30fb57e0d42 65 /** Determine if the snake collide the wall
1012754868 10:7cb79dbb351a 66 * @param lcd the subclass of N5110
1012754868 10:7cb79dbb351a 67 * @param pad the subclass of Gamepad
1012754868 4:c30fb57e0d42 68 */
1012754868 3:7b28047013d2 69 void check_WallCollision(N5110 &lcd, Gamepad &pad);
1012754868 4:c30fb57e0d42 70
1012754868 4:c30fb57e0d42 71 /** Determine if the snake collide the tail
1012754868 10:7cb79dbb351a 72 * @param lcd the subclass of N5110
1012754868 10:7cb79dbb351a 73 * @param pad the subclass of Gamepad
1012754868 4:c30fb57e0d42 74 */
1012754868 3:7b28047013d2 75 void check_TailCollision(N5110 &lcd, Gamepad &pad);
1012754868 4:c30fb57e0d42 76
1012754868 4:c30fb57e0d42 77 /** Draw the current health points and score
1012754868 10:7cb79dbb351a 78 * @param lcd the subclass of N5110
1012754868 4:c30fb57e0d42 79 */
1012754868 3:7b28047013d2 80 void drawscore(N5110 &lcd);
1012754868 4:c30fb57e0d42 81
1012754868 4:c30fb57e0d42 82 /** Make a noise when eating food
1012754868 10:7cb79dbb351a 83 * @param pad the subclass of Gamepad
1012754868 4:c30fb57e0d42 84 */
1012754868 3:7b28047013d2 85 void Tone_1(Gamepad &pad);
1012754868 4:c30fb57e0d42 86
1012754868 4:c30fb57e0d42 87 /** Make a noise when collide wall
1012754868 10:7cb79dbb351a 88 * @param pad the subclass of Gamepad
1012754868 4:c30fb57e0d42 89 */
1012754868 3:7b28047013d2 90 void game_music(Gamepad &pad);
1012754868 9:5f73221012bf 91
1012754868 3:7b28047013d2 92 int _length;
1012754868 3:7b28047013d2 93 int live;
1012754868 3:7b28047013d2 94 float waitTime;
1012754868 3:7b28047013d2 95 float waitExpect;
1012754868 3:7b28047013d2 96 int _speed;
1012754868 3:7b28047013d2 97 int Highest_score;
1012754868 3:7b28047013d2 98
1012754868 3:7b28047013d2 99
1012754868 7:cafa0b96e8d3 100
1012754868 3:7b28047013d2 101 private:
1012754868 3:7b28047013d2 102
1012754868 3:7b28047013d2 103 int _direction;
1012754868 3:7b28047013d2 104 int initx;
1012754868 3:7b28047013d2 105 int inity;
1012754868 3:7b28047013d2 106 int initl;
1012754868 3:7b28047013d2 107 int x;
1012754868 3:7b28047013d2 108 Direction d;
1012754868 3:7b28047013d2 109 Food _food;
1012754868 3:7b28047013d2 110
1012754868 3:7b28047013d2 111
1012754868 3:7b28047013d2 112 };
1012754868 3:7b28047013d2 113
1012754868 3:7b28047013d2 114 #endif