ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el17oc

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Snake Class Reference

Snake Class Reference

Snake Class Owen Cavender, University of Leeds. More...

#include <snake.h>

Public Types

enum  Directions { up }
 

deconstructor

More...

Public Member Functions

 ~Snake ()
 constructor
void get_direction (Gamepad &pad)
 initialises 'Snake' class
void render_clear_tail (N5110 &lcd)
 reads input from gamepad updates direction
void move_snake ()
 clears pixel on the end of snake before everything else on the screen is updated and rendered
void apple_collected (N5110 &lcd, Gamepad &pad)
 alters the values assigned to the snake's body based on the _direction set in get_direction
void check_gameover (N5110 &lcd)
 check to see if the apple x,y = snakehead x,y values increases score, triggers a true which causes generation of apple, updates counter Plays a tone and toggles LEDs
void get_Apple_position (N5110 &lcd)
 checks if game is over based on 3 conditions
void render (N5110 &lcd, Gamepad &pad)
 sets the apple position an update of position is triggered by bool _reset_apple
Vector2D get_Snakehead ()
 draws the snake, border, and apple during the game if it is game over, it displays the score and a gameo over message
int get_countdown ()
 returns _x0, and _y0 values
int get_score ()
 reurns counter value

Detailed Description

Snake Class Owen Cavender, University of Leeds.

Definition at line 13 of file snake.h.


Member Enumeration Documentation

enum Directions

deconstructor

Enumerator:
up 

enum of directions

Definition at line 25 of file snake.h.


Constructor & Destructor Documentation

~Snake (  )

constructor

Definition at line 8 of file snake.cpp.


Member Function Documentation

void apple_collected ( N5110 lcd,
Gamepad pad 
)

alters the values assigned to the snake's body based on the _direction set in get_direction

Definition at line 48 of file snake.cpp.

void check_gameover ( N5110 lcd )

check to see if the apple x,y = snakehead x,y values increases score, triggers a true which causes generation of apple, updates counter Plays a tone and toggles LEDs

Definition at line 78 of file snake.cpp.

void get_Apple_position ( N5110 lcd )

checks if game is over based on 3 conditions

Definition at line 292 of file snake.cpp.

int get_countdown (  )

returns _x0, and _y0 values

Definition at line 71 of file snake.cpp.

void get_direction ( Gamepad pad )

initialises 'Snake' class

Definition at line 144 of file snake.cpp.

int get_score (  )

reurns counter value

Definition at line 283 of file snake.cpp.

Vector2D get_Snakehead (  )

draws the snake, border, and apple during the game if it is game over, it displays the score and a gameo over message

Definition at line 37 of file snake.cpp.

void move_snake (  )

clears pixel on the end of snake before everything else on the screen is updated and rendered

Definition at line 185 of file snake.cpp.

void render ( N5110 lcd,
Gamepad pad 
)

sets the apple position an update of position is triggered by bool _reset_apple

print score

Definition at line 93 of file snake.cpp.

void render_clear_tail ( N5110 lcd )

reads input from gamepad updates direction

Definition at line 273 of file snake.cpp.