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
element/element.h
- Committer:
- wuweilong
- Date:
- 2019-05-08
- Revision:
- 14:65249a106a6e
- Parent:
- 13:3eb4f8dddff1
- Child:
- 15:78b28a43dd37
File content as of revision 14:65249a106a6e:
#ifndef ELEMENT_H
#define ELEMENT_H
#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
/** setting class
* @brief element class
* @author WUWEILONG 201282622
* @date May.2019
*/
class element
{
public:
/** Constructor */
element();
/** Destructor */
~element();
/** initialize the snake and the food
* @param the value of the foodsize
* @param the value of the x of coordinates of the food
* @param the value of the y of coordinates of the food
* @param the value of the x of coordinates of the snake
* @param the value of the y of coordinates of the snake
* @param the value of the snakelength
*/
void init(int foodsize,int foodx,int foody,int snakex,int snakey,int n);
/** get the position of food
*@return position of food
*/
Vector2D getfoodpos();
/** get the position of the n th segment of snake
*@return position of the n th segment of snake
*/
Vector2D getsnakepos(int n);
/** draw the graph
*@param the N5110 lcd
*@param the value of length of snake
*/
void draw(N5110 &lcd,int n);
/** upadate the coordinates of food as a random value in a specific range
*/
void update();
/** input the control
*@param the Gamepad
*/
void input(Gamepad &pad);
/** move the snake
*@param the length of snake
*/
void move(int n);
/// accessors and mutators
private:
int _size;
Vector2D _foodpos;
Vector2D _snakebody[];
Direction _d;
};
#endif