wu weilong / Mbed 2 deprecated el18w2w

Dependencies:   mbed

Committer:
wuweilong
Date:
Wed May 08 21:37:13 2019 +0000
Revision:
13:3eb4f8dddff1
Parent:
12:80e737144104
3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wuweilong 10:ae5f62a1e40e 1 #ifndef ELEMENT_H
wuweilong 10:ae5f62a1e40e 2 #define ELEMENT_H
wuweilong 10:ae5f62a1e40e 3
wuweilong 10:ae5f62a1e40e 4 #include "mbed.h"
wuweilong 10:ae5f62a1e40e 5 #include "N5110.h"
wuweilong 10:ae5f62a1e40e 6 #include "Gamepad.h"
wuweilong 10:ae5f62a1e40e 7 /** snakegame
wuweilong 10:ae5f62a1e40e 8 * @brief snakegame
wuweilong 10:ae5f62a1e40e 9 * @author WUWEILONG 201282622
wuweilong 10:ae5f62a1e40e 10 * @date May.2019
wuweilong 10:ae5f62a1e40e 11 */
wuweilong 10:ae5f62a1e40e 12 class element
wuweilong 10:ae5f62a1e40e 13 {
wuweilong 10:ae5f62a1e40e 14
wuweilong 10:ae5f62a1e40e 15 public:
wuweilong 10:ae5f62a1e40e 16 /** Constructor */
wuweilong 10:ae5f62a1e40e 17 element();
wuweilong 10:ae5f62a1e40e 18 /** Destructor */
wuweilong 10:ae5f62a1e40e 19 ~element();
wuweilong 12:80e737144104 20 /** initialize the snake and the food
wuweilong 12:80e737144104 21 * @param the value of the foodsize
wuweilong 12:80e737144104 22 * @param the value of the x of coordinates of the food
wuweilong 12:80e737144104 23 * @param the value of the y of coordinates of the food
wuweilong 12:80e737144104 24 * @param the value of the x of coordinates of the snake
wuweilong 12:80e737144104 25 * @param the value of the y of coordinates of the snake
wuweilong 12:80e737144104 26 * @param the value of the snakelength
wuweilong 12:80e737144104 27 */
wuweilong 12:80e737144104 28
wuweilong 10:ae5f62a1e40e 29 void init(int foodsize,int foodx,int foody,int snakex,int snakey,int n);
wuweilong 13:3eb4f8dddff1 30 /** get the position of food
wuweilong 13:3eb4f8dddff1 31 *@return position of food
wuweilong 13:3eb4f8dddff1 32 */
wuweilong 10:ae5f62a1e40e 33 Vector2D getfoodpos();
wuweilong 13:3eb4f8dddff1 34 /** get the position of the n th segment of snake
wuweilong 13:3eb4f8dddff1 35 *@return position of the n th segment of snake
wuweilong 13:3eb4f8dddff1 36 */
wuweilong 10:ae5f62a1e40e 37 Vector2D getsnakepos(int n);
wuweilong 13:3eb4f8dddff1 38 /** draw the graph
wuweilong 13:3eb4f8dddff1 39 *@param the N5110 lcd
wuweilong 13:3eb4f8dddff1 40 *@param the value of length of snake
wuweilong 13:3eb4f8dddff1 41 */
wuweilong 10:ae5f62a1e40e 42 void draw(N5110 &lcd,int n);
wuweilong 13:3eb4f8dddff1 43 /** upadate the coordinates of food as a random value in a specific range
wuweilong 13:3eb4f8dddff1 44 */
wuweilong 10:ae5f62a1e40e 45 void update();
wuweilong 13:3eb4f8dddff1 46 /** input the control
wuweilong 13:3eb4f8dddff1 47 *@param the Gamepad
wuweilong 13:3eb4f8dddff1 48 */
wuweilong 10:ae5f62a1e40e 49 void input(Gamepad &pad);
wuweilong 13:3eb4f8dddff1 50 /** move the snake
wuweilong 13:3eb4f8dddff1 51 *@param the length of snake
wuweilong 13:3eb4f8dddff1 52 */
wuweilong 10:ae5f62a1e40e 53 void move(int n);
wuweilong 10:ae5f62a1e40e 54
wuweilong 10:ae5f62a1e40e 55
wuweilong 10:ae5f62a1e40e 56
wuweilong 10:ae5f62a1e40e 57
wuweilong 10:ae5f62a1e40e 58 /// accessors and mutators
wuweilong 10:ae5f62a1e40e 59
wuweilong 10:ae5f62a1e40e 60 private:
wuweilong 10:ae5f62a1e40e 61
wuweilong 10:ae5f62a1e40e 62 int _size;
wuweilong 10:ae5f62a1e40e 63 Vector2D _foodpos;
wuweilong 10:ae5f62a1e40e 64 Vector2D _snakebody[];
wuweilong 10:ae5f62a1e40e 65 Direction _d;
wuweilong 10:ae5f62a1e40e 66
wuweilong 10:ae5f62a1e40e 67 };
wuweilong 10:ae5f62a1e40e 68 #endif