Fiifi Mills / Mbed 2 deprecated Snake

Dependencies:   N5110 PinDetect PowerControl mbed

Embed: (wiki syntax)

« Back to documentation index

main.h File Reference

main.h File Reference

Header file for Snake, containing functions prototypes and global variables. More...

Go to the source code of this file.

Enumerations

enum  DirectionName
 

Enumerated type used for directions read from joystick.

More...
enum  GameMenu
 

Enumerated type used to display different game menu screens.

More...

Functions

void moveSnake ()
 Implements the actual game's functionality by moving the snake and checking when certain rules have been broken.
void speedSelect ()
 Moves the selection circle in the SELECTSPEED game menu either up or down depending on the direction in which the joystick is moved.

Variables

DirectionName currentDirection
DirectionName previousDirection
GameMenu currentGameMenu
int printFlag
 Various flags used in the game for notification of specific events.
int Aflag
int Bflag
int collisionFlag
int borderFlag
int score
 Global variables.
int xCentre
int yCentre
bool gameOver
float speed
std::vector< coordinate > Snake
 Vector that contains coordinate structs, represents the snake in game.

Detailed Description

Header file for Snake, containing functions prototypes and global variables.

Revision 1.0.

Author:
Fiifi Mills
Date:
May 2015

Definition in file main.h.


Enumeration Type Documentation

Enumerated type used for directions read from joystick.

Definition at line 22 of file main.h.

enum GameMenu

Enumerated type used to display different game menu screens.

Definition at line 38 of file main.h.


Function Documentation

void moveSnake (  )

Implements the actual game's functionality by moving the snake and checking when certain rules have been broken.

Definition at line 316 of file main.cpp.

void speedSelect (  )

Moves the selection circle in the SELECTSPEED game menu either up or down depending on the direction in which the joystick is moved.

Definition at line 539 of file main.cpp.


Variable Documentation

int Aflag

Aflag set in ISR when button A pressed

Definition at line 61 of file main.h.

int Bflag

Bflag set in ISR when button B pressed

Definition at line 62 of file main.h.

borderflag set when snake collides with border in insane mode

Definition at line 64 of file main.h.

collisionflag set in moveSnake() when snake collides with self

Definition at line 63 of file main.h.

DirectionName variable used to refer to the joystick's current direction

Definition at line 31 of file main.h.

GameMenu variable used to refer to the current game menu being displayed

Definition at line 44 of file main.h.

bool gameOver

Boolean variable signifying whether or not the game is over

Definition at line 73 of file main.h.

DirectionName variable used to refer to the snake's previous direction

Definition at line 32 of file main.h.

int printFlag

Various flags used in the game for notification of specific events.

print flag set in ISR

Definition at line 60 of file main.h.

int score

Global variables.

The score that the user has accumulated throughout the game

Definition at line 70 of file main.h.

std::vector<coordinate> Snake

Vector that contains coordinate structs, represents the snake in game.

Definition at line 90 of file main.h.

float speed

The wait time used in the moveSnake function

Definition at line 74 of file main.h.

int xCentre

The x coordinate of the centre of the selection circle used in the SELECTSPEED game menu

Definition at line 71 of file main.h.

int yCentre

The y coordinate of the centre of the selection circle used in the SELECTSPEED game menu

Definition at line 72 of file main.h.