ELEC2645 (2017/18) / Mbed OS el16ajm
Embed: (wiki syntax)

« Back to documentation index

Snek Class Reference

Snek Class Reference

The Snake class. More...

#include <Snek.h>

Public Member Functions

 Snek ()
 Constructor.
 ~Snek ()
 Destructor.
void init (int x, int y)
 Initialisation function.
void update (Direction d)
 Updates the location of the snake.
int getX (int ref)
 Gets an X coordinate of the snake.
int getY (int ref)
 Gets an Y coordinate of the snake.
int getLength ()
 Gets the length of the snake.
void grow ()
 Grows the snake in length.

Detailed Description

The Snake class.

Stores the location of all the snake segments, handles movement and growth of the snake

Author:
Andrew J. Moore
Date:
May, 2018

Definition at line 14 of file Snek.h.


Constructor & Destructor Documentation

Snek (  )

Constructor.

Definition at line 4 of file Snek.cpp.

~Snek (  )

Destructor.

Definition at line 9 of file Snek.cpp.


Member Function Documentation

int getLength (  )

Gets the length of the snake.

Returns:
the value of _length

Definition at line 79 of file Snek.cpp.

int getX ( int  ref )

Gets an X coordinate of the snake.

Parameters:
theposition in the snake being referenced (int)
Returns:
the value of _x[ref]

Definition at line 69 of file Snek.cpp.

int getY ( int  ref )

Gets an Y coordinate of the snake.

Parameters:
theposition in the snake being referenced (int)
Returns:
the value of _y[ref]

Definition at line 74 of file Snek.cpp.

void grow (  )

Grows the snake in length.

Definition at line 84 of file Snek.cpp.

void init ( int  x,
int  y 
)

Initialisation function.

Parameters:
theinital starting position for the snake's head, given in X and Y (int)

Definition at line 14 of file Snek.cpp.

void update ( Direction  d )

Updates the location of the snake.

Parameters:
thejoystick's current direction (Direction)

Definition at line 32 of file Snek.cpp.