ELEC2645 (2015/16) / Mbed 2 deprecated fsmSnake

Dependencies:   N5110 mbed

Fork of fsmSnake by dean griffin

Embed: (wiki syntax)

« Back to documentation index

fsmSnakemain.h File Reference

fsmSnakemain.h File Reference

Go to the source code of this file.

Namespaces

namespace  lcd
 

lcd object


namespace  pc
 

(USBTX USBRX);


namespace  button
 

Digital in for joystick button.


namespace  xpot
 

analog in for joystick x co-ordinate


namespace  ypot
 

analog in for joystick y co-ordinate


namespace  greenLED
 

digital out for green game playing LED


namespace  redLED
 

digital out for red gameover LED


namespace  g_button_flag
 

set flag in ISR


namespace  g_timer_flag
 

set flag in ISR


namespace  menu_isr
 

update menu flag when called


namespace  button_isr
 

update button flag when called


namespace  joystick
 

creates strcut for joystick


Functions

void menu ()
 game functions
void calibrateJoystick ()
 reads joysticks x and y pots
void updateJoystick ()
 lets the joystick know which way its being pressed
void checkDirection ()
 joystick lets snake know which way to go
void gameSetup ()
 initialises game settings
void nextMoveSnake ()
 determines the snakes direction of travel
void printFood ()
 displays snake in next position
void generateFood ()
 check if the snake has ate the food, then produced next snack
void classic ()
 initialises the rules for and logic for classic snake mode
void snake2 ()
 initialises the rules for and logic for classic snake two mode
void newSnake ()
 sets snake on game area
void timer_isr ()
 called by ticker to set next screen
void update_snake_isr ()
 called by ticker to set snake in new position
void newDirection ()
 set joystick direction to snake direction
void hardWall ()
 set hardwall for classic snake mode
void wrapAround ()
 allows snake to go through to other other side in maze and snake 2 mode
void snakeTail ()
 function to make snake tail follow its head
void game_over ()
 lets player know its game over if the snake has died
void maze ()
 sets rules and logic for maze mode

Variables

volatile int g_joystickTimer_flag = 0
 flag for joystick ticker
volatile int g_gameTimer_flag = 0
 flag for gametime ticker
int i
 variable
int snakeDirection
 store direction of snake
int width [84]
 array determining game areas x axis
int height [48]
 array determining game areas y axis
int sx = 48
 snakes head on the x -axis
int sy = 24
 snakes head on the y-axis
int fx
 food on the x-axis
int fy
 food on the y-axis
int score = 0
 stores game score
int tailL = 0
 stores snake length
int tailX [100]
 array to store snake tail on x axis
int tailY [100]
 array to store snake tail on the y axis
bool gameOver = false
 true when the game is running

Detailed Description

Definition in file fsmSnakemain.h.


Function Documentation

void calibrateJoystick (  )

reads joysticks x and y pots

Definition at line 70 of file main.cpp.

void checkDirection (  )

joystick lets snake know which way to go

Definition at line 110 of file main.cpp.

void classic (  )

initialises the rules for and logic for classic snake mode

Definition at line 218 of file main.cpp.

void game_over (  )

lets player know its game over if the snake has died

Definition at line 339 of file main.cpp.

void gameSetup (  )

initialises game settings

Definition at line 325 of file main.cpp.

void generateFood (  )

check if the snake has ate the food, then produced next snack

Definition at line 205 of file main.cpp.

void hardWall (  )

set hardwall for classic snake mode

Definition at line 285 of file main.cpp.

void maze (  )

sets rules and logic for maze mode

Definition at line 262 of file main.cpp.

void menu (  )

game functions

menu function contains all of the game logic to be called in the main

Definition at line 22 of file main.cpp.

void newDirection (  )

set joystick direction to snake direction

Definition at line 155 of file main.cpp.

void newSnake (  )

sets snake on game area

Definition at line 199 of file main.cpp.

void nextMoveSnake (  )

determines the snakes direction of travel

Definition at line 132 of file main.cpp.

void printFood (  )

displays snake in next position

Definition at line 318 of file main.cpp.

void snake2 (  )

initialises the rules for and logic for classic snake two mode

Definition at line 237 of file main.cpp.

void snakeTail (  )

function to make snake tail follow its head

Definition at line 180 of file main.cpp.

void timer_isr (  )

called by ticker to set next screen

void update_snake_isr (  )

called by ticker to set snake in new position

void updateJoystick (  )

lets the joystick know which way its being pressed

Definition at line 77 of file main.cpp.

void wrapAround (  )

allows snake to go through to other other side in maze and snake 2 mode

Definition at line 293 of file main.cpp.


Variable Documentation

int fx

food on the x-axis

Definition at line 269 of file fsmSnakemain.h.

int fy

food on the y-axis

Definition at line 274 of file fsmSnakemain.h.

volatile int g_gameTimer_flag = 0

flag for gametime ticker

Definition at line 92 of file fsmSnakemain.h.

volatile int g_joystickTimer_flag = 0

flag for joystick ticker

Definition at line 88 of file fsmSnakemain.h.

bool gameOver = false

true when the game is running

Definition at line 299 of file fsmSnakemain.h.

int height[48]

array determining game areas y axis

Definition at line 254 of file fsmSnakemain.h.

int i

variable

Definition at line 241 of file fsmSnakemain.h.

int score = 0

stores game score

Definition at line 279 of file fsmSnakemain.h.

store direction of snake

Definition at line 246 of file fsmSnakemain.h.

int sx = 48

snakes head on the x -axis

Definition at line 259 of file fsmSnakemain.h.

int sy = 24

snakes head on the y-axis

Definition at line 264 of file fsmSnakemain.h.

int tailL = 0

stores snake length

Definition at line 284 of file fsmSnakemain.h.

int tailX[100]

array to store snake tail on x axis

Definition at line 289 of file fsmSnakemain.h.

int tailY[100]

array to store snake tail on the y axis

Definition at line 294 of file fsmSnakemain.h.

int width[84]

array determining game areas x axis

Definition at line 250 of file fsmSnakemain.h.