Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
snake/snake.h@20:980b37fde361, 2018-05-08 (annotated)
- Committer:
 - weiway
 - Date:
 - Tue May 08 13:41:08 2018 +0000
 - Revision:
 - 20:980b37fde361
 - Parent:
 - 15:47ea86f1ed70
 
adding doxygen documentation , comments and references
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| weiway | 10:946a3835a7c7 | 1 | #ifndef SNAKE_H | 
| weiway | 10:946a3835a7c7 | 2 | #define SNAKE_H | 
| weiway | 10:946a3835a7c7 | 3 | |
| weiway | 10:946a3835a7c7 | 4 | #include "mbed.h" | 
| weiway | 10:946a3835a7c7 | 5 | #include "N5110.h" | 
| weiway | 10:946a3835a7c7 | 6 | #include "Gamepad.h" | 
| weiway | 20:980b37fde361 | 7 | |
| weiway | 20:980b37fde361 | 8 | /** snake class | 
| weiway | 20:980b37fde361 | 9 | *author wei wei | 
| weiway | 20:980b37fde361 | 10 | *date 30th , April | 
| weiway | 20:980b37fde361 | 11 | @breif the head file of snake which drawing and moving the snake | 
| weiway | 20:980b37fde361 | 12 | */ | 
| weiway | 20:980b37fde361 | 13 | |
| weiway | 20:980b37fde361 | 14 | |
| weiway | 0:d557f30e3a95 | 15 | class snake | 
| weiway | 0:d557f30e3a95 | 16 | { | 
| weiway | 1:6bcf09972c0d | 17 | public: | 
| weiway | 1:6bcf09972c0d | 18 | |
| weiway | 0:d557f30e3a95 | 19 | snake(); | 
| weiway | 1:6bcf09972c0d | 20 | ~snake(); | 
| weiway | 20:980b37fde361 | 21 | void init();//initialise the snake | 
| weiway | 20:980b37fde361 | 22 | void update(Direction d,float mag);//update the direction of the snake, controlled by joysitck | 
| weiway | 20:980b37fde361 | 23 | void draw(N5110 &lcd);//draw the snake. | 
| weiway | 20:980b37fde361 | 24 | Vector2D get_pos(); //This return the position of the snanke. Get from the Pong sample code. | 
| weiway | 20:980b37fde361 | 25 | void set_pos(Vector2D p);//Set the position of snake in 2D vector. From pong sample code. | 
| weiway | 20:980b37fde361 | 26 | void point();//the number of fruit that snake ate | 
| weiway | 20:980b37fde361 | 27 | int get_point();//a function to capture the point | 
| weiway | 15:47ea86f1ed70 | 28 | |
| weiway | 15:47ea86f1ed70 | 29 | private: | 
| weiway | 15:47ea86f1ed70 | 30 | |
| weiway | 20:980b37fde361 | 31 | int _point;//value of the player gets | 
| weiway | 20:980b37fde361 | 32 | int _array;//array of pixel | 
| weiway | 20:980b37fde361 | 33 | int dir_snake;//direction of snake | 
| weiway | 20:980b37fde361 | 34 | void s();//move snake to south direction | 
| weiway | 20:980b37fde361 | 35 | void n();//move snake to north direction | 
| weiway | 20:980b37fde361 | 36 | void e();//move snake to east direction | 
| weiway | 20:980b37fde361 | 37 | void w();//move snake to west direction | 
| weiway | 20:980b37fde361 | 38 | int _xoldpos[100];//old x position of snake .MAX 100 pixel | 
| weiway | 20:980b37fde361 | 39 | int _yoldpos[100];//old y position of snake | 
| weiway | 20:980b37fde361 | 40 | int _xnewpos[100];//new x position | 
| weiway | 20:980b37fde361 | 41 | int _ynewpos[100];//new y position | 
| weiway | 0:d557f30e3a95 | 42 | }; | 
| weiway | 0:d557f30e3a95 | 43 | #endif | 
| weiway | 0:d557f30e3a95 | 44 | |
| weiway | 0:d557f30e3a95 | 45 | |
| weiway | 0:d557f30e3a95 | 46 | |
| weiway | 0:d557f30e3a95 | 47 | |
| weiway | 0:d557f30e3a95 | 48 | |
| weiway | 0:d557f30e3a95 | 49 | |
| weiway | 0:d557f30e3a95 | 50 | |
| weiway | 0:d557f30e3a95 | 51 | |
| weiway | 0:d557f30e3a95 | 52 | |
| weiway | 0:d557f30e3a95 | 53 |