Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of fsmSnake by
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 checkDirection | ( | ) |
void classic | ( | ) |
void game_over | ( | ) |
void generateFood | ( | ) |
void menu | ( | ) |
void newDirection | ( | ) |
void nextMoveSnake | ( | ) |
void snake2 | ( | ) |
void snakeTail | ( | ) |
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 | ( | ) |
void wrapAround | ( | ) |
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.
int snakeDirection |
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.
Generated on Fri Aug 5 2022 08:44:17 by
