Peng Jingran / Mbed 2 deprecated Snake_copy

Dependencies:   mbed FXOS8700Q

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Snake.h Source File

Snake.h

00001 #ifndef SNAKE_H
00002 #define SNAKE_H
00003 
00004 #include "Food.h"
00005 #include <math.h>
00006 #include <stdlib.h>
00007 #include "Gamepad.h"
00008 #include "mbed.h"
00009 #include "N5110.h"
00010 
00011 /** pos struct */
00012 struct snakePart{
00013     
00014     char _x[4000];/**< char for x value */
00015     char _y[4000];/**< char for y value */
00016     char _dir[4000];/**< char for dir value */
00017     
00018     };
00019 
00020 //libraies including
00021 
00022 /** Snake Class 
00023  * @brief Does nothing useful 
00024  * @author Du Xianjie 
00025  * @date May, 2019 
00026  */ 
00027 
00028 class Snake{
00029     
00030     public:
00031     
00032         /** Constructor */ 
00033         Snake();
00034         /** Destructor */ 
00035         ~Snake();
00036         
00037         /** Set the draw
00038          * @param the figure (N5110 &lcd) 
00039          */
00040         void draw(N5110 &lcd);
00041         /** Set the gamepad
00042          * @param screen (Gamepad &pad) 
00043          */
00044         void update(Gamepad &pad);
00045         /** Set the deadsnake
00046          * @param dead snake(N5110 &lcd) 
00047          */
00048         void deadSnake(N5110 &lcd);
00049         /** Set the inital snake
00050          * @param initial snake(int x, int y, int lenght,int _live) 
00051          */
00052         void init(int x, int y, int lenght,int _live);
00053         /** Set the point
00054          * @param food point() 
00055          */
00056         void addPoint();
00057         /** Check the wall collision
00058          * @param collision(N5110 &lcd) 
00059          */
00060         void checkWallCollision(N5110 &lcd);
00061         /** Check the tail collision
00062          * @param collision(N5110 &lcd) 
00063          */
00064         void checkTailCollision(N5110 &lcd);
00065         /** Show the score
00066          * @param score(N5110 &lcd) 
00067          */
00068         void drawScore(N5110 &lcd);
00069         /** Show the length
00070          * @return length(_length) 
00071          */
00072          
00073         int _length;
00074         int live;
00075         int waitTime;
00076     
00077         float waitCount;
00078        
00079           
00080     private:
00081         
00082         
00083         int _speed;
00084         int _direction;
00085         
00086         int startx;
00087         int starty;
00088         int startl;
00089         int x;
00090         
00091         Direction d;
00092         Food _food;
00093         
00094         
00095 };//definition of variable and functions
00096     
00097     #endif