ELEC2645 (2018/19) / Mbed 2 deprecated ml17z4c_attempt2

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Game Class Reference

Game Class Reference

The Game class. More...

#include <Game.h>

Public Member Functions

 Game ()
 Constructor.
 ~Game ()
 Destructor.
void init (int x, int y)
 init function
void update (Direction d)
 Updates coordinate of snake.
int getLength ()
 Gets snake length.
void grow ()
 add snake length by 1
int xcoordinate (int now)
 Gets x coordinate of the snake.
int ycoordinate (int now)
 Gets y coordinate of the snake.

Data Fields

char Previous_direction
 the previous direction of snake
int _x [4032]
 the _y and _y array

Detailed Description

The Game class.

the functions of game roles

Author:
ZIYI CHEN
Date:
May 2019

Definition at line 12 of file Game.h.


Constructor & Destructor Documentation

Game (  )

Constructor.

Definition at line 4 of file Game.cpp.

~Game (  )

Destructor.

Definition at line 9 of file Game.cpp.


Member Function Documentation

int getLength (  )

Gets snake length.

Returns:
the value of snake length

Definition at line 78 of file Game.cpp.

void grow (  )

add snake length by 1

Definition at line 83 of file Game.cpp.

void init ( int  x,
int  y 
)

init function

Parameters:
initalstarting coordinate of snake head.

Definition at line 14 of file Game.cpp.

void update ( Direction  d )

Updates coordinate of snake.

Parameters:
thejoystick'direction

Definition at line 30 of file Game.cpp.

int xcoordinate ( int  now )

Gets x coordinate of the snake.

Parameters:
theposition of snake in x coorinate
Returns:
value of _x[now]

Definition at line 89 of file Game.cpp.

int ycoordinate ( int  now )

Gets y coordinate of the snake.

Parameters:
theposition of snake in y coorinate
Returns:
value of _y[now]

Definition at line 94 of file Game.cpp.


Field Documentation

int _x[4032]

the _y and _y array

Definition at line 60 of file Game.h.

the previous direction of snake

Definition at line 52 of file Game.h.