wu weilong / Mbed 2 deprecated el18w2w

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

element Class Reference

element Class Reference

snakegame More...

#include <element.h>

Public Member Functions

 element ()
 Constructor.
 ~element ()
 Destructor.
void init (int foodsize, int foodx, int foody, int snakex, int snakey, int n)
 initialize the snake and the food
Vector2D getfoodpos ()
 get the position of food
Vector2D getsnakepos (int n)
 get the position of the n th segment of snake
void draw (N5110 &lcd, int n)
 draw the graph
void update ()
 upadate the coordinates of food as a random value in a specific range
void input (Gamepad &pad)
 input the control
void move (int n)
 move the snake

Detailed Description

snakegame

snakegame

Author:
WUWEILONG 201282622
Date:
May.2019

Definition at line 12 of file element.h.


Constructor & Destructor Documentation

element (  )

Constructor.

Definition at line 2 of file element.cpp.

~element (  )

Destructor.

Definition at line 7 of file element.cpp.


Member Function Documentation

void draw ( N5110 lcd,
int  n 
)

draw the graph

Parameters:
theN5110 lcd
thevalue of length of snake

Definition at line 36 of file element.cpp.

Vector2D getfoodpos (  )

get the position of food

Returns:
position of food

Definition at line 31 of file element.cpp.

Vector2D getsnakepos ( int  n )

get the position of the n th segment of snake

Returns:
position of the n th segment of snake

Definition at line 113 of file element.cpp.

void init ( int  foodsize,
int  foodx,
int  foody,
int  snakex,
int  snakey,
int  n 
)

initialize the snake and the food

Parameters:
thevalue of the foodsize
thevalue of the x of coordinates of the food
thevalue of the y of coordinates of the food
thevalue of the x of coordinates of the snake
thevalue of the y of coordinates of the snake
thevalue of the snakelength

Definition at line 11 of file element.cpp.

void input ( Gamepad pad )

input the control

Parameters:
theGamepad

Definition at line 42 of file element.cpp.

void move ( int  n )

move the snake

Parameters:
thelength of snake

Definition at line 45 of file element.cpp.

void update (  )

upadate the coordinates of food as a random value in a specific range

Definition at line 22 of file element.cpp.