wu weilong / Mbed 2 deprecated el18w2w

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers element.h Source File

element.h

00001 #ifndef ELEMENT_H
00002 #define ELEMENT_H
00003 
00004 #include "mbed.h"
00005 #include "N5110.h"
00006 #include "Gamepad.h"
00007 /** snakegame
00008 * @brief snakegame
00009 * @author WUWEILONG 201282622
00010 * @date May.2019
00011 */
00012 class element
00013 {
00014 
00015 public:
00016      /** Constructor */
00017      element();
00018       /** Destructor */
00019     ~element();
00020   /** initialize the snake and the food  
00021   * @param the value of the foodsize 
00022   * @param the value of the x of coordinates of the food
00023   * @param the value of the y of coordinates of the food
00024   * @param the value of the x of coordinates of the snake
00025   * @param the value of the y of coordinates of the snake
00026   * @param the value of the snakelength
00027   */
00028   
00029     void init(int foodsize,int foodx,int foody,int snakex,int snakey,int n);
00030     /** get the position of food
00031     *@return position of food 
00032     */
00033     Vector2D getfoodpos();
00034     /** get the position of the n th segment of snake
00035     *@return position of the n th segment of snake 
00036     */
00037     Vector2D getsnakepos(int n);
00038     /** draw the graph 
00039     *@param the N5110 lcd
00040     *@param the value of length of snake
00041     */
00042     void draw(N5110 &lcd,int n);
00043     /** upadate the coordinates of food as a random value in a specific range
00044     */
00045     void update();
00046     /** input the control 
00047     *@param the Gamepad
00048     */
00049     void input(Gamepad &pad);
00050     /**  move the snake 
00051     *@param the length of snake 
00052     */
00053     void move(int n);
00054     
00055     
00056     
00057    
00058     /// accessors and mutators
00059     
00060 private:
00061 
00062     int _size;
00063     Vector2D _foodpos;
00064     Vector2D _snakebody[];
00065     Direction _d;
00066     
00067 };
00068 #endif