ELEC2645 (2018/19) / Mbed 2 deprecated el18jz_

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Move Class Reference

Move Class Reference

Move Class. More...

#include <Move.h>

Public Member Functions

 Move ()
 Constructor.
 ~Move ()
 Destructor.
void initial ()
 initial all the parameter for the snake and food.
void onlcd (N5110 &lcd)
 Print snake, walls and food on LCD.
void update (Gamepad &pad)
 Update new direction and snake head.
void updatebody ()
 Update whole snakebody.
void getfood ()
 Use random number to generate a new food on screen while old food has benn eaten.
void die (N5110 &lcd, Gamepad &pad)
 check if snake head collide the wall or its body.
void eatfood ()
 check if snake head hit the food.

Detailed Description

Move Class.

Class for main engine for the snake game

Author:
Zhou Jiaxin
Date:
8th May 2019

Definition at line 31 of file Move.h.


Constructor & Destructor Documentation

Move (  )

Constructor.

Definition at line 7 of file Move.cpp.

~Move (  )

Destructor.

Definition at line 11 of file Move.cpp.


Member Function Documentation

void die ( N5110 lcd,
Gamepad pad 
)

check if snake head collide the wall or its body.

Parameters:
N5110*lcd

pointer to the N5110 object in main, address of this pointer is saved to make availability to the entire class, without passing address to each function.

Parameters:
Gamepad*pad

pointer to the gamepad object in main, address of this pointer is saved to make availability to the entire class, without passing address to each function.

Definition at line 88 of file Move.cpp.

void eatfood (  )

check if snake head hit the food.

Definition at line 133 of file Move.cpp.

void getfood (  )

Use random number to generate a new food on screen while old food has benn eaten.

Definition at line 31 of file Move.cpp.

void initial (  )

initial all the parameter for the snake and food.

Definition at line 15 of file Move.cpp.

void onlcd ( N5110 lcd )

Print snake, walls and food on LCD.

Parameters:
N5110*lcd

pointer to the N5110 object in main, address of this pointer is saved to make availability to the entire class, without passing address to each function.

Definition at line 48 of file Move.cpp.

void update ( Gamepad pad )

Update new direction and snake head.

Parameters:
Gamepad*pad

pointer to the gamepad object in main, address of this pointer is saved to make availability to the entire class, without passing address to each function.

Definition at line 60 of file Move.cpp.

void updatebody (  )

Update whole snakebody.

Definition at line 37 of file Move.cpp.