ELEC2645 (2015/16) / Mbed 2 deprecated Robozoec_Era

Dependencies:   N5110 SDFileSystem gameCharacters mbed

Embed: (wiki syntax)

« Back to documentation index

main.cpp File Reference

main.cpp File Reference

Revision 1.0. More...

Go to the source code of this file.

Functions

void initialize_values ()
 Initializes all game values so that when the game ends everything returns to it's normal state.
void ticker_wait (int t)
 Waits for t/10 seconds, a more energy efficient but same funtionality as wait()
void readSD_progress ()
 Reads the Pregress file on the SD card.
void writeSD_progress ()
 Writes the current game progress onto the Progress file on the SD card.
void readSD_and_print_top_score ()
 Reads the Highscores file on the SD card and prints the 5 highest numbers in the Highscores array on the lcd screen.
void writeSD ()
 Writes the topscore on the 6th position in the Highscores array (so it doesn't overwrite any values that are already stored)
void delete_file (char filename[])
 Funtion to delete a file.
void Delete_Highscores ()
 Delete the Highscores file.
void sort_top_scores ()
 Sorts the values and orders them in descending order.
void play_music ()
 Plays the next note form song1 array on the piezo buzzer.
void generate_random_number ()
 Generates a random munber between 0 and 9999 using the clock on the mbed as a source for the srand() funtion.
void led_bar ()
 Displayes the current number of lives on the led bar.
void ground ()
 Prints the floor on the LCD.
void print_heart ()
 Prints the g_heart array on the LCD.
void print_ammo_pickUp ()
 Prints the g_ammo_pickUP on the LCD.
void print_speed_boost ()
 Prints the g_speed_boost on the LCD.
void print_recks_still_gun ()
 Prints Recks (main character), the g_recks_still_gun array on the LCD.
void print_recks_moving_gun ()
 Prints the g_recks_moving_gun array on the LCD.
void print_recks_crouch_gun ()
 Prints the g_recks_crouch_gun array on the LCD.
void print_recks_shield ()
 Prints the g_recks_shield array on the LCD.
void print_recks_jump_gun ()
 Prints the g_recks_jump_gun array on the LCD.
void print_recks_falling ()
 Prints the g_recks_falling array on the LCD.
void print_mob_rat_p1 ()
 Prints the g_mob_rat_p1 (position 1) array on the LCD.
void print_mob_rat_p2 ()
 Prints the g_mob_rat_p2 (position 2) array on the LCD.
void print_mob_hound_p1 ()
 Prints the g_mob_hound_p1 (position 1) array on the LCD.
void print_mob_hound_p2 ()
 Prints the g_mob_hound_p2 (position 2) array on the LCD.
void print_mob_hound_dead ()
 Prints the g_mob_hound_dead array on the LCD.
void print_mob_bear_p1 ()
 Prints the g_mob_bear_p1 (position 1) array on the LCD.
void print_mob_bear_p2 ()
 Prints the g_mob_bear_p2 (position 2) array on the LCD.
void print_mob_bear_dead ()
 Prints the g_mob_bear_dead array on the LCD.
void print_mob_bird_p1 ()
 Prints the g_mob_bird_p1 (position 1) array on the LCD.
void print_mob_bird_p2 ()
 Prints the g_mob_bird_p2 (position 2) array on the LCD.
void print_mob_bird_dead ()
 Prints the g_mob_bear_dead array on the LCD.
void print_cactus ()
 Prints the cactus array on the LCD.
void print_quick_sand ()
 Prints a line of lengh 16 one pixel above the ground.
void print_t_rex ()
 Prints the g_t_rex array on the LCD.
void print_t_rex_moving ()
 Prints the g_t_rex_moving array on the LCD.
void print_t_rex_attack ()
 Prints the g_t_rex_attack array on the LCD.
void print_fire_ball_p1 ()
 Prints the g_fire_ball_p1 (position 1) array on the LCD.
void print_fire_ball_p2 ()
 Prints the g_fire_ball_p2 (position 2) array on the LCD.
void print_clouds ()
 Prints the g_clouds array on the LCD.
void print_locks ()
 Prints the g_clouds array on the LCD.
void falling_animation ()
 Prints animation of Recks sinking in quick sand.
void intro ()
 Prints the name of the game for 3 seconds when it's turned on.
void Ticker_Menu_isr ()
 Funtion that sets g_Ticker_Menu_flag=1.
void Ticker_Game_isr ()
 Funtion that sets g_Ticker_Game_flag=1.
void Ticker_ds_isr ()
 Funtion that sets g_Ticker_ds_flag=1.
void music_tOut ()
 Funtion that sets PWM.period=0.0, so that the tune stops when it times-out.
void press_b_A_isr ()
 Funtion that sets g_press_b_A_flag=1.
void press_b_B_isr ()
 Funtion that sets g_press_b_B_flag=1.
void calibrateJoystick ()
 Funtion that reads the joystick position when it is still and form those readings it allocates values of xPot and yPot that are equicalent to the directions UP, DOWN, LEFT, RIGHT, CENTRE.
void updateJoystick ()
 Reads the current values of xPot and yPot and detemins the position of the joysick.
void main_menu ()
 Funtion that pritns the main menu options and allows the user to select one of the options by pressing the button A.
void Minigame ()
 Funtion that runs the game without the sory mode.
void Story_Mode ()
 Funtion that pritns the story mode menu options and allows the user to select one of the chapters by pressing the button A or returning to the main menu by pressing the button B.
void Tutorial ()
 Funtion that prints sequential text introducing the game, and the game funtions.
void Chapter1 ()
 Funtion that prints sequential text introducing the story and then runs the game on a easy difficulty setting.
void Chapter2 ()
 Funtion that prints sequential text expanding the story and then runs the game on a increased difficulty setting.
void Chapter3 ()
 Funtion that prints sequential text expanding the story and then runs the game on a increased difficulty setting.
void Chapter4 ()
 Funtion that prints sequential text expanding the story and then runs the game with a final boss fight.
void Settings ()
 Funtion that pritns the settings menu options and allows the user to select one of the options by pressing the button A or returning to the main menu by pressing the button B.
void Difficulty ()
 Funtion that pritns the difficulty menu options and allows the user to select one of the different difficulties by pressing the button A or returning to the main menu by pressing the button B.
void Brightness ()
 Funtion that pritns the brightness menu options and allows the user to select one of the different brightnesses by pressing the button A or returning to the main menu by pressing the button B.
void Leaderboard ()
 Funtion that allows the user to view the highscores and returning to the main menu by pressing the button B.
void guns ()
 Funtion that pritns the guns options and allows the user to select one of the different guns by pressing the button A or returning to the main menu by pressing the button B.
void Credits ()
 Prints the credits on the LCD.
void Recks ()
 Funtion that contols the motion, physics and interations of Recks with the other interactive elements.
void rat ()
 Funtion that contols the motion, physics and interations of the rat with Recks.
void hound ()
 Funtion that contols the motion, physics and interations of the hound with Recks.
void bear ()
 Funtion that contols the motion, physics and interations of the bear with Recks.
void bird ()
 Funtion that contols the motion, physics and interations of the bird with Recks.
void cactus ()
 Funtion that contols the motion, physics and interations of the cactus with Recks.
void t_rex ()
 Funtion that contols the motion, physics and interations of the T Rex with Recks.
void fire_ball ()
 Funtion that contols the motion, physics and interations of the fire ball with Recks.
void quick_sand ()
 Funtion that contols the motion, physics and interations of the quick sand with Recks.
void heart ()
 Funtion that contols the motion, physics and interations of the heart pickup with Recks.
void pickUp_ammo ()
 Funtion that contols the motion, physics and interations of the ammo pickup with Recks.
void speed_boost ()
 Funtion that contols the motion, physics and interations of the speed boost with Recks.
void shield ()
 Funtion that turns on the shield.
void Game ()
 Funtion that runs the game.
void Pause ()
 Funtion that stops the game and powers down the LED's until the joystick button is pressed.
void set_difficulty ()
 This funtion sets flags for printing interactive elements, depending on the difficulty leavel selected.
int Game_over ()
 Funtion that runs when the lives global variable is 0.
void print_ammo ()
 Pritns "AMMO" and the remaining ammo on the top right of the LCD screen.
void print_score ()
 Prints "SCORE" and the current score value on the top left of the LCD screen.

Detailed Description

Revision 1.0.

Author:
Robin Milward Cooney
Date:
May 2015

Definition in file main.cpp.


Function Documentation

void bear (  )

Funtion that contols the motion, physics and interations of the bear with Recks.

Definition at line 2458 of file main.cpp.

void bird (  )

Funtion that contols the motion, physics and interations of the bird with Recks.

Definition at line 2494 of file main.cpp.

void Brightness (  )

Funtion that pritns the brightness menu options and allows the user to select one of the different brightnesses by pressing the button A or returning to the main menu by pressing the button B.

Definition at line 2083 of file main.cpp.

void cactus (  )

Funtion that contols the motion, physics and interations of the cactus with Recks.

Definition at line 2538 of file main.cpp.

void calibrateJoystick (  )

Funtion that reads the joystick position when it is still and form those readings it allocates values of xPot and yPot that are equicalent to the directions UP, DOWN, LEFT, RIGHT, CENTRE.

Definition at line 939 of file main.cpp.

void Chapter1 (  )

Funtion that prints sequential text introducing the story and then runs the game on a easy difficulty setting.

Definition at line 1460 of file main.cpp.

void Chapter2 (  )

Funtion that prints sequential text expanding the story and then runs the game on a increased difficulty setting.

Definition at line 1690 of file main.cpp.

void Chapter3 (  )

Funtion that prints sequential text expanding the story and then runs the game on a increased difficulty setting.

Definition at line 1751 of file main.cpp.

void Chapter4 (  )

Funtion that prints sequential text expanding the story and then runs the game with a final boss fight.

Definition at line 1829 of file main.cpp.

void Credits (  )

Prints the credits on the LCD.

Definition at line 2216 of file main.cpp.

void delete_file ( char  filename[] )

Funtion to delete a file.

Parameters:
filename[]- Name of file that is to be deleted

Definition at line 206 of file main.cpp.

void Delete_Highscores (  )

Delete the Highscores file.

Definition at line 221 of file main.cpp.

void Difficulty (  )

Funtion that pritns the difficulty menu options and allows the user to select one of the different difficulties by pressing the button A or returning to the main menu by pressing the button B.

Definition at line 2030 of file main.cpp.

void falling_animation (  )

Prints animation of Recks sinking in quick sand.

Definition at line 872 of file main.cpp.

void fire_ball (  )

Funtion that contols the motion, physics and interations of the fire ball with Recks.

Definition at line 2592 of file main.cpp.

void Game (  )

Funtion that runs the game.

Definition at line 2724 of file main.cpp.

int Game_over (  )

Funtion that runs when the lives global variable is 0.

Printing a game over message

Returns:
0 or 1. 0 returns back to the main menu and 1 re-plays the game after initializing values

Definition at line 2990 of file main.cpp.

void generate_random_number (  )

Generates a random munber between 0 and 9999 using the clock on the mbed as a source for the srand() funtion.

Definition at line 292 of file main.cpp.

void ground (  )

Prints the floor on the LCD.

Definition at line 309 of file main.cpp.

void guns (  )

Funtion that pritns the guns options and allows the user to select one of the different guns by pressing the button A or returning to the main menu by pressing the button B.

Definition at line 2154 of file main.cpp.

void heart (  )

Funtion that contols the motion, physics and interations of the heart pickup with Recks.

Definition at line 2656 of file main.cpp.

void hound (  )

Funtion that contols the motion, physics and interations of the hound with Recks.

Definition at line 2397 of file main.cpp.

void initialize_values (  )

Initializes all game values so that when the game ends everything returns to it's normal state.

Definition at line 41 of file main.cpp.

void intro (  )

Prints the name of the game for 3 seconds when it's turned on.

Definition at line 887 of file main.cpp.

void Leaderboard (  )

Funtion that allows the user to view the highscores and returning to the main menu by pressing the button B.

Definition at line 2136 of file main.cpp.

void led_bar (  )

Displayes the current number of lives on the led bar.

Definition at line 300 of file main.cpp.

void main_menu (  )

Funtion that pritns the main menu options and allows the user to select one of the options by pressing the button A.

Definition at line 970 of file main.cpp.

void Minigame (  )

Funtion that runs the game without the sory mode.

Definition at line 1035 of file main.cpp.

void music_tOut (  )

Funtion that sets PWM.period=0.0, so that the tune stops when it times-out.

Definition at line 918 of file main.cpp.

void Pause (  )

Funtion that stops the game and powers down the LED's until the joystick button is pressed.

Definition at line 2869 of file main.cpp.

void pickUp_ammo (  )

Funtion that contols the motion, physics and interations of the ammo pickup with Recks.

Definition at line 2672 of file main.cpp.

void play_music (  )

Plays the next note form song1 array on the piezo buzzer.

Definition at line 273 of file main.cpp.

void press_b_A_isr (  )

Funtion that sets g_press_b_A_flag=1.

Definition at line 925 of file main.cpp.

void press_b_B_isr (  )

Funtion that sets g_press_b_B_flag=1.

Definition at line 932 of file main.cpp.

void print_ammo (  )

Pritns "AMMO" and the remaining ammo on the top right of the LCD screen.

Definition at line 3022 of file main.cpp.

void print_ammo_pickUp (  )

Prints the g_ammo_pickUP on the LCD.

Definition at line 370 of file main.cpp.

void print_cactus (  )

Prints the cactus array on the LCD.

Definition at line 709 of file main.cpp.

void print_clouds (  )

Prints the g_clouds array on the LCD.

Definition at line 825 of file main.cpp.

void print_fire_ball_p1 (  )

Prints the g_fire_ball_p1 (position 1) array on the LCD.

Definition at line 789 of file main.cpp.

void print_fire_ball_p2 (  )

Prints the g_fire_ball_p2 (position 2) array on the LCD.

Definition at line 807 of file main.cpp.

void print_heart (  )

Prints the g_heart array on the LCD.

Definition at line 352 of file main.cpp.

void print_locks (  )

Prints the g_clouds array on the LCD.

It prints it multiple times next to the corresponding chapter. They are either locked or unlocked depending on the story_progress value

Definition at line 841 of file main.cpp.

void print_mob_bear_dead (  )

Prints the g_mob_bear_dead array on the LCD.

Definition at line 641 of file main.cpp.

void print_mob_bear_p1 (  )

Prints the g_mob_bear_p1 (position 1) array on the LCD.

Definition at line 605 of file main.cpp.

void print_mob_bear_p2 (  )

Prints the g_mob_bear_p2 (position 2) array on the LCD.

Definition at line 623 of file main.cpp.

void print_mob_bird_dead (  )

Prints the g_mob_bear_dead array on the LCD.

Definition at line 695 of file main.cpp.

void print_mob_bird_p1 (  )

Prints the g_mob_bird_p1 (position 1) array on the LCD.

Definition at line 659 of file main.cpp.

void print_mob_bird_p2 (  )

Prints the g_mob_bird_p2 (position 2) array on the LCD.

Definition at line 677 of file main.cpp.

void print_mob_hound_dead (  )

Prints the g_mob_hound_dead array on the LCD.

Definition at line 587 of file main.cpp.

void print_mob_hound_p1 (  )

Prints the g_mob_hound_p1 (position 1) array on the LCD.

Definition at line 551 of file main.cpp.

void print_mob_hound_p2 (  )

Prints the g_mob_hound_p2 (position 2) array on the LCD.

Definition at line 569 of file main.cpp.

void print_mob_rat_p1 (  )

Prints the g_mob_rat_p1 (position 1) array on the LCD.

Definition at line 515 of file main.cpp.

void print_mob_rat_p2 (  )

Prints the g_mob_rat_p2 (position 2) array on the LCD.

Definition at line 533 of file main.cpp.

void print_quick_sand (  )

Prints a line of lengh 16 one pixel above the ground.

Definition at line 727 of file main.cpp.

void print_recks_crouch_gun (  )

Prints the g_recks_crouch_gun array on the LCD.

Definition at line 443 of file main.cpp.

void print_recks_falling (  )

Prints the g_recks_falling array on the LCD.

Definition at line 497 of file main.cpp.

void print_recks_jump_gun (  )

Prints the g_recks_jump_gun array on the LCD.

Definition at line 479 of file main.cpp.

void print_recks_moving_gun (  )

Prints the g_recks_moving_gun array on the LCD.

Definition at line 424 of file main.cpp.

void print_recks_shield (  )

Prints the g_recks_shield array on the LCD.

Definition at line 461 of file main.cpp.

void print_recks_still_gun (  )

Prints Recks (main character), the g_recks_still_gun array on the LCD.

Definition at line 405 of file main.cpp.

void print_score (  )

Prints "SCORE" and the current score value on the top left of the LCD screen.

Definition at line 3169 of file main.cpp.

void print_speed_boost (  )

Prints the g_speed_boost on the LCD.

Definition at line 388 of file main.cpp.

void print_t_rex (  )

Prints the g_t_rex array on the LCD.

Definition at line 735 of file main.cpp.

void print_t_rex_attack (  )

Prints the g_t_rex_attack array on the LCD.

Definition at line 771 of file main.cpp.

void print_t_rex_moving (  )

Prints the g_t_rex_moving array on the LCD.

Definition at line 753 of file main.cpp.

void quick_sand (  )

Funtion that contols the motion, physics and interations of the quick sand with Recks.

Definition at line 2637 of file main.cpp.

void rat (  )

Funtion that contols the motion, physics and interations of the rat with Recks.

Definition at line 2369 of file main.cpp.

void readSD_and_print_top_score (  )

Reads the Highscores file on the SD card and prints the 5 highest numbers in the Highscores array on the lcd screen.

Definition at line 159 of file main.cpp.

void readSD_progress (  )

Reads the Pregress file on the SD card.

Definition at line 124 of file main.cpp.

void Recks (  )

Funtion that contols the motion, physics and interations of Recks with the other interactive elements.

Definition at line 2240 of file main.cpp.

void set_difficulty (  )

This funtion sets flags for printing interactive elements, depending on the difficulty leavel selected.

Definition at line 2891 of file main.cpp.

void Settings (  )

Funtion that pritns the settings menu options and allows the user to select one of the options by pressing the button A or returning to the main menu by pressing the button B.

Definition at line 1982 of file main.cpp.

void shield (  )

Funtion that turns on the shield.

Definition at line 2705 of file main.cpp.

void sort_top_scores (  )

Sorts the values and orders them in descending order.

Definition at line 256 of file main.cpp.

void speed_boost (  )

Funtion that contols the motion, physics and interations of the speed boost with Recks.

Definition at line 2689 of file main.cpp.

void Story_Mode (  )

Funtion that pritns the story mode menu options and allows the user to select one of the chapters by pressing the button A or returning to the main menu by pressing the button B.

Definition at line 1052 of file main.cpp.

void t_rex (  )

Funtion that contols the motion, physics and interations of the T Rex with Recks.

Definition at line 2558 of file main.cpp.

void Ticker_ds_isr (  )

Funtion that sets g_Ticker_ds_flag=1.

Definition at line 911 of file main.cpp.

void Ticker_Game_isr (  )

Funtion that sets g_Ticker_Game_flag=1.

Definition at line 904 of file main.cpp.

void Ticker_Menu_isr (  )

Funtion that sets g_Ticker_Menu_flag=1.

Definition at line 897 of file main.cpp.

void ticker_wait ( int  t )

Waits for t/10 seconds, a more energy efficient but same funtionality as wait()

Parameters:
t- time in 0.1*seconds

Definition at line 112 of file main.cpp.

void Tutorial (  )

Funtion that prints sequential text introducing the game, and the game funtions.

Definition at line 1109 of file main.cpp.

void updateJoystick (  )

Reads the current values of xPot and yPot and detemins the position of the joysick.

Definition at line 946 of file main.cpp.

void writeSD (  )

Writes the topscore on the 6th position in the Highscores array (so it doesn't overwrite any values that are already stored)

Definition at line 187 of file main.cpp.

void writeSD_progress (  )

Writes the current game progress onto the Progress file on the SD card.

Definition at line 141 of file main.cpp.