Robin Milward Cooney 200849894
Dependencies: N5110 SDFileSystem gameCharacters mbed
main.h@3:4b254b4bd6d4, 2016-05-05 (annotated)
- Committer:
- robinmc
- Date:
- Thu May 05 14:59:45 2016 +0000
- Revision:
- 3:4b254b4bd6d4
Fun game
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| robinmc | 3:4b254b4bd6d4 | 1 | /** |
| robinmc | 3:4b254b4bd6d4 | 2 | @file main.h |
| robinmc | 3:4b254b4bd6d4 | 3 | @brief Revision 1.0. |
| robinmc | 3:4b254b4bd6d4 | 4 | @author Robin Milward Cooney |
| robinmc | 3:4b254b4bd6d4 | 5 | @date May 2015 |
| robinmc | 3:4b254b4bd6d4 | 6 | */ |
| robinmc | 3:4b254b4bd6d4 | 7 | |
| robinmc | 3:4b254b4bd6d4 | 8 | //--------------------------------------INCLUSIONS--------------------------------------------------- |
| robinmc | 3:4b254b4bd6d4 | 9 | |
| robinmc | 3:4b254b4bd6d4 | 10 | #include "mbed.h" |
| robinmc | 3:4b254b4bd6d4 | 11 | #include "N5110.h" |
| robinmc | 3:4b254b4bd6d4 | 12 | #include "math.h" |
| robinmc | 3:4b254b4bd6d4 | 13 | #include "stdint.h" |
| robinmc | 3:4b254b4bd6d4 | 14 | #include "SDFileSystem.h" |
| robinmc | 3:4b254b4bd6d4 | 15 | #include "gameCharacters.h" |
| robinmc | 3:4b254b4bd6d4 | 16 | |
| robinmc | 3:4b254b4bd6d4 | 17 | //--------------------------------------------------------------------------------------------------- |
| robinmc | 3:4b254b4bd6d4 | 18 | |
| robinmc | 3:4b254b4bd6d4 | 19 | //-------------------------------------DEFINITIONS--------------------------------------------------- |
| robinmc | 3:4b254b4bd6d4 | 20 | |
| robinmc | 3:4b254b4bd6d4 | 21 | #define joystickTolerance 0.05f |
| robinmc | 3:4b254b4bd6d4 | 22 | |
| robinmc | 3:4b254b4bd6d4 | 23 | //--------------------------------------------------------------------------------------------------- |
| robinmc | 3:4b254b4bd6d4 | 24 | |
| robinmc | 3:4b254b4bd6d4 | 25 | //--------------------------------------NAMESPACES--------------------------------------------------- |
| robinmc | 3:4b254b4bd6d4 | 26 | |
| robinmc | 3:4b254b4bd6d4 | 27 | /** |
| robinmc | 3:4b254b4bd6d4 | 28 | @namespace lcd |
| robinmc | 3:4b254b4bd6d4 | 29 | @brief Output pins for lcd screen pin order: VCC,SCE,RST,D/C,MOSI,SCLK,LED |
| robinmc | 3:4b254b4bd6d4 | 30 | */ |
| robinmc | 3:4b254b4bd6d4 | 31 | N5110 lcd(PTE26,PTA0,PTC4,PTD0,PTD2,PTD1,PTC3); |
| robinmc | 3:4b254b4bd6d4 | 32 | |
| robinmc | 3:4b254b4bd6d4 | 33 | /** |
| robinmc | 3:4b254b4bd6d4 | 34 | @namespace led |
| robinmc | 3:4b254b4bd6d4 | 35 | @brief LED bus output, each pinout represents a LED on a LED bar, from bottom to top |
| robinmc | 3:4b254b4bd6d4 | 36 | */ |
| robinmc | 3:4b254b4bd6d4 | 37 | BusOut led(PTC8,PTC9,PTC0,PTC7,PTC5); |
| robinmc | 3:4b254b4bd6d4 | 38 | |
| robinmc | 3:4b254b4bd6d4 | 39 | /** |
| robinmc | 3:4b254b4bd6d4 | 40 | @namespace sd |
| robinmc | 3:4b254b4bd6d4 | 41 | @brief SD card output, the pins are in the following order: MOSI, MISO, SCK, CS |
| robinmc | 3:4b254b4bd6d4 | 42 | */ |
| robinmc | 3:4b254b4bd6d4 | 43 | SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); |
| robinmc | 3:4b254b4bd6d4 | 44 | |
| robinmc | 3:4b254b4bd6d4 | 45 | /** |
| robinmc | 3:4b254b4bd6d4 | 46 | @namespace red_led |
| robinmc | 3:4b254b4bd6d4 | 47 | @brief Red LED output on mbed, used for error messages and debugging when reading and or writing on SD card |
| robinmc | 3:4b254b4bd6d4 | 48 | */ |
| robinmc | 3:4b254b4bd6d4 | 49 | DigitalOut red_led(LED_RED); |
| robinmc | 3:4b254b4bd6d4 | 50 | |
| robinmc | 3:4b254b4bd6d4 | 51 | /** |
| robinmc | 3:4b254b4bd6d4 | 52 | @namespace green_led |
| robinmc | 3:4b254b4bd6d4 | 53 | @brief Green LED output on mbed, used for success messages when reading and or writing on SD card |
| robinmc | 3:4b254b4bd6d4 | 54 | */ |
| robinmc | 3:4b254b4bd6d4 | 55 | DigitalOut green_led(LED_GREEN); |
| robinmc | 3:4b254b4bd6d4 | 56 | |
| robinmc | 3:4b254b4bd6d4 | 57 | /** |
| robinmc | 3:4b254b4bd6d4 | 58 | @namespace swJoy |
| robinmc | 3:4b254b4bd6d4 | 59 | @brief Switch on potentiomiter. DigitalIn and to be polled using a ticker |
| robinmc | 3:4b254b4bd6d4 | 60 | */ |
| robinmc | 3:4b254b4bd6d4 | 61 | DigitalIn swJoy(PTB18); //define potentiomiter switch |
| robinmc | 3:4b254b4bd6d4 | 62 | |
| robinmc | 3:4b254b4bd6d4 | 63 | /** |
| robinmc | 3:4b254b4bd6d4 | 64 | @namespace xPot |
| robinmc | 3:4b254b4bd6d4 | 65 | @brief AnalogIn that correspods the horizontal movement of the joystick |
| robinmc | 3:4b254b4bd6d4 | 66 | */ |
| robinmc | 3:4b254b4bd6d4 | 67 | AnalogIn xPot(PTB2); |
| robinmc | 3:4b254b4bd6d4 | 68 | |
| robinmc | 3:4b254b4bd6d4 | 69 | /** |
| robinmc | 3:4b254b4bd6d4 | 70 | @namespace yPot |
| robinmc | 3:4b254b4bd6d4 | 71 | @brief AnalogIn that correspods the virtical movement of the joystick |
| robinmc | 3:4b254b4bd6d4 | 72 | */ |
| robinmc | 3:4b254b4bd6d4 | 73 | AnalogIn yPot(PTB3); |
| robinmc | 3:4b254b4bd6d4 | 74 | |
| robinmc | 3:4b254b4bd6d4 | 75 | /** |
| robinmc | 3:4b254b4bd6d4 | 76 | @namespace b_A |
| robinmc | 3:4b254b4bd6d4 | 77 | @brief Additional pushbutton (PullDown). DigitalIn and to be polled using a ticker |
| robinmc | 3:4b254b4bd6d4 | 78 | */ |
| robinmc | 3:4b254b4bd6d4 | 79 | DigitalIn b_A(PTE24); |
| robinmc | 3:4b254b4bd6d4 | 80 | |
| robinmc | 3:4b254b4bd6d4 | 81 | /** |
| robinmc | 3:4b254b4bd6d4 | 82 | @namespace b_A |
| robinmc | 3:4b254b4bd6d4 | 83 | @brief Additional pushbutton (PullDown). DigitalIn and to be polled using a ticker |
| robinmc | 3:4b254b4bd6d4 | 84 | */ |
| robinmc | 3:4b254b4bd6d4 | 85 | DigitalIn b_B(PTE25); |
| robinmc | 3:4b254b4bd6d4 | 86 | |
| robinmc | 3:4b254b4bd6d4 | 87 | /** |
| robinmc | 3:4b254b4bd6d4 | 88 | @namespace press_bA |
| robinmc | 3:4b254b4bd6d4 | 89 | @brief IterruptIn corresponding to the pushbutton A (PullDown). To be used when polling using a ticker is inconvinient or inefficient |
| robinmc | 3:4b254b4bd6d4 | 90 | */ |
| robinmc | 3:4b254b4bd6d4 | 91 | InterruptIn press_b_A(PTE24); |
| robinmc | 3:4b254b4bd6d4 | 92 | |
| robinmc | 3:4b254b4bd6d4 | 93 | /** |
| robinmc | 3:4b254b4bd6d4 | 94 | @namespace press_bA |
| robinmc | 3:4b254b4bd6d4 | 95 | @brief IterruptIn corresponding to the pushbutton B (PullDown). To be used when polling using a ticker is inconvinient or inefficient |
| robinmc | 3:4b254b4bd6d4 | 96 | */ |
| robinmc | 3:4b254b4bd6d4 | 97 | InterruptIn press_b_B(PTE25); |
| robinmc | 3:4b254b4bd6d4 | 98 | |
| robinmc | 3:4b254b4bd6d4 | 99 | /** |
| robinmc | 3:4b254b4bd6d4 | 100 | @namespace PWM |
| robinmc | 3:4b254b4bd6d4 | 101 | @brief Pulse width modulation output conected to buzzer to contol the music |
| robinmc | 3:4b254b4bd6d4 | 102 | */ |
| robinmc | 3:4b254b4bd6d4 | 103 | PwmOut PWM(PTC11); |
| robinmc | 3:4b254b4bd6d4 | 104 | |
| robinmc | 3:4b254b4bd6d4 | 105 | |
| robinmc | 3:4b254b4bd6d4 | 106 | /** |
| robinmc | 3:4b254b4bd6d4 | 107 | @namespace Ticker_Menu |
| robinmc | 3:4b254b4bd6d4 | 108 | @brief Ticker used for polling the joysick and the digital inputs while the menu funtions are running |
| robinmc | 3:4b254b4bd6d4 | 109 | */ |
| robinmc | 3:4b254b4bd6d4 | 110 | Ticker Ticker_Menu; |
| robinmc | 3:4b254b4bd6d4 | 111 | |
| robinmc | 3:4b254b4bd6d4 | 112 | /** |
| robinmc | 3:4b254b4bd6d4 | 113 | @namespace Ticker_Game |
| robinmc | 3:4b254b4bd6d4 | 114 | @brief Ticker used for polling the joysick and the digital inputs while the game funtion is running |
| robinmc | 3:4b254b4bd6d4 | 115 | */ |
| robinmc | 3:4b254b4bd6d4 | 116 | Ticker Ticker_Game; |
| robinmc | 3:4b254b4bd6d4 | 117 | |
| robinmc | 3:4b254b4bd6d4 | 118 | /** |
| robinmc | 3:4b254b4bd6d4 | 119 | @namespace Ticker_ds |
| robinmc | 3:4b254b4bd6d4 | 120 | @brief Ticker used to create a more energy efficient wait() funtion |
| robinmc | 3:4b254b4bd6d4 | 121 | */ |
| robinmc | 3:4b254b4bd6d4 | 122 | Ticker Ticker_ds; |
| robinmc | 3:4b254b4bd6d4 | 123 | |
| robinmc | 3:4b254b4bd6d4 | 124 | /** |
| robinmc | 3:4b254b4bd6d4 | 125 | @namespace tOut |
| robinmc | 3:4b254b4bd6d4 | 126 | @brief Timeout used to implement music. It turns the buzzer off at the correct moment |
| robinmc | 3:4b254b4bd6d4 | 127 | */ |
| robinmc | 3:4b254b4bd6d4 | 128 | Timeout tOut; |
| robinmc | 3:4b254b4bd6d4 | 129 | |
| robinmc | 3:4b254b4bd6d4 | 130 | /** |
| robinmc | 3:4b254b4bd6d4 | 131 | @namespace Highscores |
| robinmc | 3:4b254b4bd6d4 | 132 | @brief File that stores an array of the top 5 highscores |
| robinmc | 3:4b254b4bd6d4 | 133 | */ |
| robinmc | 3:4b254b4bd6d4 | 134 | FILE *Highscores; |
| robinmc | 3:4b254b4bd6d4 | 135 | |
| robinmc | 3:4b254b4bd6d4 | 136 | /** |
| robinmc | 3:4b254b4bd6d4 | 137 | @namespace Progress |
| robinmc | 3:4b254b4bd6d4 | 138 | @brief File that stores the progress (i.e unlocked chapeters) of the Story Mode |
| robinmc | 3:4b254b4bd6d4 | 139 | */ |
| robinmc | 3:4b254b4bd6d4 | 140 | FILE *Progress; |
| robinmc | 3:4b254b4bd6d4 | 141 | |
| robinmc | 3:4b254b4bd6d4 | 142 | //-------------------------------------------------------------------------------------- |
| robinmc | 3:4b254b4bd6d4 | 143 | |
| robinmc | 3:4b254b4bd6d4 | 144 | //---------------------------------VARIABLES-------------------------------------------- |
| robinmc | 3:4b254b4bd6d4 | 145 | |
| robinmc | 3:4b254b4bd6d4 | 146 | int i=0; /*!< Loop counter for the game() funtion */ |
| robinmc | 3:4b254b4bd6d4 | 147 | int recks_movement=2; /*!< Global variable that deffines the direction of all mobs with respect to Recks (main character)*/ |
| robinmc | 3:4b254b4bd6d4 | 148 | int g_jump=36; /*!< Global variable that deffines the vertical possition of Recks and the bullet during the jumping action*/ |
| robinmc | 3:4b254b4bd6d4 | 149 | int jumpUp; /*!< Global variable that flags depending on the direction of Recks while jumping. 0 when going up, 1 when going down*/ |
| robinmc | 3:4b254b4bd6d4 | 150 | int accel=0; /*!< Global variable that changes every loop during the jump to increase or decrease the velociry of Recks during the jump. Providing real time physics*/ |
| robinmc | 3:4b254b4bd6d4 | 151 | int hound_jump=0; /*!< Global variable that changes every loop during the jump to increase or decrease the velociry of the hound during the jump. Providing real time physics*/ |
| robinmc | 3:4b254b4bd6d4 | 152 | int fall=37; /*!< Variable that deffines the vertical possition of Recks when he is in Quick sand, decreases at a constant velocity*/ |
| robinmc | 3:4b254b4bd6d4 | 153 | int bullet=9; /*!< Global variable that deffines the horizontal possition of the bullet*/ |
| robinmc | 3:4b254b4bd6d4 | 154 | int bullet_height; /*!< Global variable that deffines the vertical possition of the bullet*/ |
| robinmc | 3:4b254b4bd6d4 | 155 | int menu_select; /*!< Global variable, it the output of the fsm that deffines what item on the menus have been selected*/ |
| robinmc | 3:4b254b4bd6d4 | 156 | int menuState=0; /*!< Global variable, it is the current state of the fsm*/ |
| robinmc | 3:4b254b4bd6d4 | 157 | double lives=4; /*!< Global variable that indicates the number of lives Recks has*/ |
| robinmc | 3:4b254b4bd6d4 | 158 | int score=0; /*!< Global variable inticating the overall number of points achieved duning the game, it is the variable saved to the highscores[] array after. |
| robinmc | 3:4b254b4bd6d4 | 159 | Score=h_movement/10+killscore-shield_score*/ |
| robinmc | 3:4b254b4bd6d4 | 160 | int kill_score; /*!< Global variable inticating the number of points achieved duning by destroying the mobsr*/ |
| robinmc | 3:4b254b4bd6d4 | 161 | int shield_score; /*!< Global variable counting the ammount of times the shield has been used and for every time it decreases the overall score by 10 points*/ |
| robinmc | 3:4b254b4bd6d4 | 162 | int shield_counter=0; /*!< Global variable that counts the number of loops the shield has been "On" for*/ |
| robinmc | 3:4b254b4bd6d4 | 163 | int h_movement=0; /*!< Global variable that counts the distance travelled by Recks, and is used |
| robinmc | 3:4b254b4bd6d4 | 164 | to contol the horizontal possition of the clouds. Diffrent to recks_movement in order so the |
| robinmc | 3:4b254b4bd6d4 | 165 | forgrond can move faster than than the background giving it a sense of perspective. Also used |
| robinmc | 3:4b254b4bd6d4 | 166 | to calcualte the score.*/ |
| robinmc | 3:4b254b4bd6d4 | 167 | int ammo=24; /*!< Global variable indicating the number of bullets left to use, decreases when a bullet is shot, increasis when ammo is picked up*/ |
| robinmc | 3:4b254b4bd6d4 | 168 | int g_shoot_loop=0; /*!< Global variable that prevents a bullet beeing shot while there is already a bullet on screen, when the bullet is onscreen it is >0 otherwhise it is 0*/ |
| robinmc | 3:4b254b4bd6d4 | 169 | int fire_on_screen=0; /*!< Global variable that prevents another fireball beeing shot while there is already a fire ball on screen, when the fire ball is onscreen it is >0 otherwhise it is 0*/ |
| robinmc | 3:4b254b4bd6d4 | 170 | int story_mode_flag=0; /*!< Global variable that flags when the player is in the story mode, rather than in the minigame */ |
| robinmc | 3:4b254b4bd6d4 | 171 | int lose_lives_delay_flag=0; /*!< Global variable that flags when the player loses a life and resets to 0 after 1 second. This means that there is a recovery time after losing a life*/ |
| robinmc | 3:4b254b4bd6d4 | 172 | int lives_delay_loop=0; /*!< Global variable indicating the number of times the lose_lives_delay_flag statement has iterated, after a certain numeer of itterations it resets the |
| robinmc | 3:4b254b4bd6d4 | 173 | flag and the value to 0. Mening the revovery time is over*/ |
| robinmc | 3:4b254b4bd6d4 | 174 | int difficulty=2; /*!< Global variable that dictates the probability of certain flags swtiching, i.e it it's low then less enemies appear therefore the game is easier*/ |
| robinmc | 3:4b254b4bd6d4 | 175 | int story_progress=1; /*!< Global variable that indicates the story mode progress, it increases after each chapter then autosaves to the Progress file on SD card*/ |
| robinmc | 3:4b254b4bd6d4 | 176 | int g_story_mode_win=0; /*!< Global variable that indicates whether the final chapter is complete*/ |
| robinmc | 3:4b254b4bd6d4 | 177 | int bear_lives=0; /*!< Global vairable that indicates the number of bullets taken by the bear/3*/ |
| robinmc | 3:4b254b4bd6d4 | 178 | int t_rex_lives=0; /*!< Global vairable that indicates the number of bullets taken by the T Rex/3*/ |
| robinmc | 3:4b254b4bd6d4 | 179 | int g_music_count=1; /*!< Global vairable that indicates the location of the note in the song array*/ |
| robinmc | 3:4b254b4bd6d4 | 180 | int g_top_scores[6]; /*!< Global array that stores the 6 top scores, only the 5 highest are printed*/ |
| robinmc | 3:4b254b4bd6d4 | 181 | float brightness=0.5; /*!< Global vairable that indicated the brighntness of the lcd screen*/ |
| robinmc | 3:4b254b4bd6d4 | 182 | int random_num; /*!< Global vairable, random number created in the generate_random_number() funtion*/ |
| robinmc | 3:4b254b4bd6d4 | 183 | int g_g1; /*!< Global vaiable that is is 1 when the players selects revolver*/ |
| robinmc | 3:4b254b4bd6d4 | 184 | int g_g2; /*!< Global vaiable that is is 1 when the players selects rifle*/ |
| robinmc | 3:4b254b4bd6d4 | 185 | |
| robinmc | 3:4b254b4bd6d4 | 186 | //******************MOVEMENT GLOBAL VARIABLES******************* |
| robinmc | 3:4b254b4bd6d4 | 187 | // These global variables indicate the horizontal (or vertical) movement of all the different interactive elements (mobs, pick ups, speed boosts...) |
| robinmc | 3:4b254b4bd6d4 | 188 | //If it's horizontal movement it is indicated by either "element name"_movement or "element name"_hMovement the vertical movement is indicaded by "element name"_vMovement |
| robinmc | 3:4b254b4bd6d4 | 189 | int rat_movement=95; /*!< Global variable indicating the horizontal movement of the rat*/ |
| robinmc | 3:4b254b4bd6d4 | 190 | int hound_hMovement=98; /*!< Global variable indicating the horizontal movement of the hound*/ |
| robinmc | 3:4b254b4bd6d4 | 191 | int hound_vMovement=40; /*!< Global variable indicating the vertical movement of the hound*/ |
| robinmc | 3:4b254b4bd6d4 | 192 | int bear_movement=100; /*!< Global variable indicating the horizontal movement of the bear*/ |
| robinmc | 3:4b254b4bd6d4 | 193 | int bird_hMovement=95; /*!< Global variable indicating the horizontal movement of the bird*/ |
| robinmc | 3:4b254b4bd6d4 | 194 | int bird_vMovement=20; /*!< Global variable indicating the vertical movement of the bird*/ |
| robinmc | 3:4b254b4bd6d4 | 195 | int cactus_movement=110; /*!< Global variable indicating the horizontal movement of the cactus*/ |
| robinmc | 3:4b254b4bd6d4 | 196 | int t_rex_movement=120; /*!< Global variable indicating the horizontal movement of the T Rex*/ |
| robinmc | 3:4b254b4bd6d4 | 197 | int quick_sand_movement=85; /*!< Global variable indicating the horizontal movement of the Quick sand*/ |
| robinmc | 3:4b254b4bd6d4 | 198 | int fire_ball_hMovement=t_rex_movement-6; /*!< Global variable indicating the horizontal movement of the fire ball made by the T Rex*/ |
| robinmc | 3:4b254b4bd6d4 | 199 | int fire_ball_vMovement=25; /*!< Global variable indicating the vertical movement of the fire ball made by the T Rex*/ |
| robinmc | 3:4b254b4bd6d4 | 200 | int heart_movement=90; /*!< Global variable indicating the horizontal movement of the fire ball made by the heart pick up*/ |
| robinmc | 3:4b254b4bd6d4 | 201 | int ammo_movement=100; /*!< Global variable indicating the horizontal movement of the fire ball made by the ammo pick up*/ |
| robinmc | 3:4b254b4bd6d4 | 202 | int speed_boost_movement=130; /*!< Global variable indicating the horizontal movement of the fire ball made by the speed boost pick up*/ |
| robinmc | 3:4b254b4bd6d4 | 203 | //************************************************************** |
| robinmc | 3:4b254b4bd6d4 | 204 | |
| robinmc | 3:4b254b4bd6d4 | 205 | //*****FLAGS FOR ACCTIONS AND PRINTING INTERACTIVE ELEMENTS***** |
| robinmc | 3:4b254b4bd6d4 | 206 | //These falgs are randomly activated (more or less frequently depending on the difficulty). For interactive elements when the flag is "On" (=1) the |
| robinmc | 3:4b254b4bd6d4 | 207 | //element is printed, the flag is then cleared when the element either moves offscreen or is destroyed or picked up. For the action flags (jump, shoot |
| robinmc | 3:4b254b4bd6d4 | 208 | //shield) the flag is cleared when the action is over. |
| robinmc | 3:4b254b4bd6d4 | 209 | int jump_flag=0; /*!< Global variable that flags (=1) when the jump button is pressed and unflags(=0) when the jump has finished*/ |
| robinmc | 3:4b254b4bd6d4 | 210 | int shoot_flag=0; /*!< Global variable that flags (=1) when the shoot button is pressed and unflags(=0) when the bulllet has left the screen*/ |
| robinmc | 3:4b254b4bd6d4 | 211 | int shield_flag=0; /*!< Global variable that flags (=1) when the shield is activated (joystick pointed upwards)and unflags(=0) after 1 second*/ |
| robinmc | 3:4b254b4bd6d4 | 212 | int print_rat_flag=0; /*!< Global variable that flags (=1) randomly and prints the rat onscreen. It unflags(=0) when the rat leaves the screen*/ |
| robinmc | 3:4b254b4bd6d4 | 213 | int print_hound_flag=0; /*!< Global variable that flags (=1) randomly and prints the hound onscreen. It unflags(=0) when the hound leaves the screen or is destroyed*/ |
| robinmc | 3:4b254b4bd6d4 | 214 | int hound_jump_flag=0; /*!< Global variable that flags (=1) randomly to make the hound jump. It unflags(=0) when the jump is over*/ |
| robinmc | 3:4b254b4bd6d4 | 215 | int print_bear_flag=0; /*!< Global variable that flags (=1) randomly and prints the bear onscreen. It unflags(=0) when the bear leaves the screen or is destroyed*/ |
| robinmc | 3:4b254b4bd6d4 | 216 | int print_bird_flag=0; /*!< Global variable that flags (=1) randomly and prints the bird onscreen. It unflags(=0) when the bird leaves the screen or is destroyed*/ |
| robinmc | 3:4b254b4bd6d4 | 217 | int print_heart_flag=0; /*!< Global variable that flags (=1) randomly and prints the heart pickup onscreen. It unflags(=0) when the pickup leaves the screen or is picked up*/ |
| robinmc | 3:4b254b4bd6d4 | 218 | int print_ammo_flag=0; /*!< Global variable that flags (=1) randomly and prints the ammo pickup onscreen. It unflags(=0) when the pickup leaves the screen or is picked up*/ |
| robinmc | 3:4b254b4bd6d4 | 219 | int print_speed_boost_flag=0; /*!< Global variable that flags (=1) randomly and prints the speed boost pickup onscreen. It unflags(=0) when the pickup leaves the screen or is picked up*/ |
| robinmc | 3:4b254b4bd6d4 | 220 | int print_cactus_flag=0; /*!< Global variable that flags (=1) randomly and prints the cactus onscreen. It unflags(=0) when the cactus leaves the screen*/ |
| robinmc | 3:4b254b4bd6d4 | 221 | int print_t_rex_flag=0; /*!< Global variable that flags (=1) randomly and prints the T Rex onscreen. It unflags(=0) when the T Rex leaves the screen or is destroyed*/ |
| robinmc | 3:4b254b4bd6d4 | 222 | int print_fire_ball_flag=0; /*!< Global variable that flags (=1) randomly when the print_t_rex_flag is flagged and prints the T Rex onscreen. It unflags(=0) when the fire ball leaves the screen*/ |
| robinmc | 3:4b254b4bd6d4 | 223 | int print_quick_sand_flag=0; /*!< Global variable that flags (=1) randomly and prints the quicksand onscreen. It unflags(=0) when the quicksand leaves the screen*/ |
| robinmc | 3:4b254b4bd6d4 | 224 | //**************************************************************** |
| robinmc | 3:4b254b4bd6d4 | 225 | |
| robinmc | 3:4b254b4bd6d4 | 226 | //*******************FLAGS FOR TICKERS AND INTERRUPTS************* |
| robinmc | 3:4b254b4bd6d4 | 227 | volatile int g_Ticker_Menu_flag=0; /*!<Global variable to flag the menu ticker*/ |
| robinmc | 3:4b254b4bd6d4 | 228 | volatile int g_Ticker_Game_flag=0; /*!<Global variable to flag the game ticker*/ |
| robinmc | 3:4b254b4bd6d4 | 229 | volatile int g_Ticker_Music_flag=0; /*!<Global variable to flag the music ticker*/ |
| robinmc | 3:4b254b4bd6d4 | 230 | volatile int g_Ticker_ds_flag=0; /*!<Global variable to flag the ticker for the ticker wait funtion*/ |
| robinmc | 3:4b254b4bd6d4 | 231 | volatile int g_press_b_A_flag=0; /*!<Global variable to flag the Interrupt of button A*/ |
| robinmc | 3:4b254b4bd6d4 | 232 | volatile int g_press_b_B_flag=0; /*!<Global variable to flag the Interrupt of button B*/ |
| robinmc | 3:4b254b4bd6d4 | 233 | //***************************************************************** |
| robinmc | 3:4b254b4bd6d4 | 234 | |
| robinmc | 3:4b254b4bd6d4 | 235 | //***********************FINITE STATE MACHINE********************** |
| robinmc | 3:4b254b4bd6d4 | 236 | struct menuState { /*!<Struct declaring the fsm */ |
| robinmc | 3:4b254b4bd6d4 | 237 | int menu_select; |
| robinmc | 3:4b254b4bd6d4 | 238 | int nextState[5]; |
| robinmc | 3:4b254b4bd6d4 | 239 | }; |
| robinmc | 3:4b254b4bd6d4 | 240 | typedef const struct menuState STyp; |
| robinmc | 3:4b254b4bd6d4 | 241 | |
| robinmc | 3:4b254b4bd6d4 | 242 | STyp fsm_main_menu[5] = { |
| robinmc | 3:4b254b4bd6d4 | 243 | {0,{0,1,4,0,0}}, |
| robinmc | 3:4b254b4bd6d4 | 244 | {8,{1,2,0,1,1}}, |
| robinmc | 3:4b254b4bd6d4 | 245 | {16,{2,3,1,2,2}}, |
| robinmc | 3:4b254b4bd6d4 | 246 | {24,{3,4,2,3,3}}, |
| robinmc | 3:4b254b4bd6d4 | 247 | {32,{4,0,3,4,4}} |
| robinmc | 3:4b254b4bd6d4 | 248 | }; |
| robinmc | 3:4b254b4bd6d4 | 249 | |
| robinmc | 3:4b254b4bd6d4 | 250 | STyp fsm_settings_menu[5] = { |
| robinmc | 3:4b254b4bd6d4 | 251 | {0,{0,1,2,0,0}}, |
| robinmc | 3:4b254b4bd6d4 | 252 | {8,{1,2,0,1,1}}, |
| robinmc | 3:4b254b4bd6d4 | 253 | {16,{2,3,1,2,2}}, |
| robinmc | 3:4b254b4bd6d4 | 254 | {24,{3,0,2,3,3}}, |
| robinmc | 3:4b254b4bd6d4 | 255 | {32,{4,4,4,4,4}} |
| robinmc | 3:4b254b4bd6d4 | 256 | }; |
| robinmc | 3:4b254b4bd6d4 | 257 | //***************************************************************** |
| robinmc | 3:4b254b4bd6d4 | 258 | |
| robinmc | 3:4b254b4bd6d4 | 259 | enum joystickDirection { //enum type for every neccessary direction of the joystick |
| robinmc | 3:4b254b4bd6d4 | 260 | CENTRE, //when the joystick isn't moved |
| robinmc | 3:4b254b4bd6d4 | 261 | DOWN, |
| robinmc | 3:4b254b4bd6d4 | 262 | UP, |
| robinmc | 3:4b254b4bd6d4 | 263 | LEFT, |
| robinmc | 3:4b254b4bd6d4 | 264 | RIGHT, |
| robinmc | 3:4b254b4bd6d4 | 265 | }; |
| robinmc | 3:4b254b4bd6d4 | 266 | |
| robinmc | 3:4b254b4bd6d4 | 267 | typedef struct JoyStick Joystick; //struct for Joystick |
| robinmc | 3:4b254b4bd6d4 | 268 | struct JoyStick { |
| robinmc | 3:4b254b4bd6d4 | 269 | float x; // current x value |
| robinmc | 3:4b254b4bd6d4 | 270 | float x0; // 'centred' x value |
| robinmc | 3:4b254b4bd6d4 | 271 | float y; // current y value |
| robinmc | 3:4b254b4bd6d4 | 272 | float y0; // 'centred' y value |
| robinmc | 3:4b254b4bd6d4 | 273 | int swJoy; // button state (assume pull-down used, so 1 = pressed, 0 = unpressed) |
| robinmc | 3:4b254b4bd6d4 | 274 | joystickDirection direction; // current direction |
| robinmc | 3:4b254b4bd6d4 | 275 | }; |
| robinmc | 3:4b254b4bd6d4 | 276 | |
| robinmc | 3:4b254b4bd6d4 | 277 | // create struct variable |
| robinmc | 3:4b254b4bd6d4 | 278 | Joystick joystick; |
| robinmc | 3:4b254b4bd6d4 | 279 | |
| robinmc | 3:4b254b4bd6d4 | 280 | |
| robinmc | 3:4b254b4bd6d4 | 281 | |
| robinmc | 3:4b254b4bd6d4 | 282 | //------------------------------------------------------------------------------------------------------------------ |
| robinmc | 3:4b254b4bd6d4 | 283 | |
| robinmc | 3:4b254b4bd6d4 | 284 | //---------------------------------------------FUNTIONS------------------------------------------------------------- |
| robinmc | 3:4b254b4bd6d4 | 285 | |
| robinmc | 3:4b254b4bd6d4 | 286 | /// Initializes all game values so that when the game ends everything returns to it's normal state |
| robinmc | 3:4b254b4bd6d4 | 287 | void initialize_values(); |
| robinmc | 3:4b254b4bd6d4 | 288 | |
| robinmc | 3:4b254b4bd6d4 | 289 | /**Waits for t/10 seconds, a more energy efficient but same funtionality as wait() |
| robinmc | 3:4b254b4bd6d4 | 290 | @param t - time in 0.1*seconds*/ |
| robinmc | 3:4b254b4bd6d4 | 291 | void ticker_wait(int t); |
| robinmc | 3:4b254b4bd6d4 | 292 | |
| robinmc | 3:4b254b4bd6d4 | 293 | ///Generates a random munber between 0 and 9999 using the clock on the mbed as a source for the srand() funtion |
| robinmc | 3:4b254b4bd6d4 | 294 | void generate_random_number(); |
| robinmc | 3:4b254b4bd6d4 | 295 | |
| robinmc | 3:4b254b4bd6d4 | 296 | ///Displayes the current number of lives on the led bar |
| robinmc | 3:4b254b4bd6d4 | 297 | void led_bar(); |
| robinmc | 3:4b254b4bd6d4 | 298 | |
| robinmc | 3:4b254b4bd6d4 | 299 | ///Plays the next note form song1 array on the piezo buzzer |
| robinmc | 3:4b254b4bd6d4 | 300 | void play_music(); |
| robinmc | 3:4b254b4bd6d4 | 301 | |
| robinmc | 3:4b254b4bd6d4 | 302 | //*******************TICKERS, INTERUPTS AND TIMEOUTS**************** |
| robinmc | 3:4b254b4bd6d4 | 303 | ///Funtion that sets g_Ticker_Menu_flag=1 |
| robinmc | 3:4b254b4bd6d4 | 304 | void Ticker_Menu_isr(); |
| robinmc | 3:4b254b4bd6d4 | 305 | |
| robinmc | 3:4b254b4bd6d4 | 306 | ///Funtion that sets g_Ticker_Game_flag=1 |
| robinmc | 3:4b254b4bd6d4 | 307 | void Ticker_Game_isr(); |
| robinmc | 3:4b254b4bd6d4 | 308 | |
| robinmc | 3:4b254b4bd6d4 | 309 | ///Funtion that sets g_Ticker_ds_flag=1 |
| robinmc | 3:4b254b4bd6d4 | 310 | void Ticker_ds_isr(); |
| robinmc | 3:4b254b4bd6d4 | 311 | |
| robinmc | 3:4b254b4bd6d4 | 312 | ///Funtion that sets PWM.period=0.0, so that the tune stops when it times-out |
| robinmc | 3:4b254b4bd6d4 | 313 | void music_tOut(); |
| robinmc | 3:4b254b4bd6d4 | 314 | |
| robinmc | 3:4b254b4bd6d4 | 315 | ///Funtion that sets g_press_b_A_flag=1 |
| robinmc | 3:4b254b4bd6d4 | 316 | void press_b_A_isr(); |
| robinmc | 3:4b254b4bd6d4 | 317 | |
| robinmc | 3:4b254b4bd6d4 | 318 | ///Funtion that sets g_press_b_B_flag=1 |
| robinmc | 3:4b254b4bd6d4 | 319 | void press_b_B_isr(); |
| robinmc | 3:4b254b4bd6d4 | 320 | |
| robinmc | 3:4b254b4bd6d4 | 321 | //******************************************************************* |
| robinmc | 3:4b254b4bd6d4 | 322 | |
| robinmc | 3:4b254b4bd6d4 | 323 | //******************************JOYSTICK***************************** |
| robinmc | 3:4b254b4bd6d4 | 324 | /**Funtion that reads the joystick position when it is still and form those readings it allocates |
| robinmc | 3:4b254b4bd6d4 | 325 | values of xPot and yPot that are equicalent to the directions UP, DOWN, LEFT, RIGHT, CENTRE*/ |
| robinmc | 3:4b254b4bd6d4 | 326 | void calibrateJoystick(); |
| robinmc | 3:4b254b4bd6d4 | 327 | |
| robinmc | 3:4b254b4bd6d4 | 328 | /**Reads the current values of xPot and yPot and detemins the position of the joysick*/ |
| robinmc | 3:4b254b4bd6d4 | 329 | void updateJoystick(); |
| robinmc | 3:4b254b4bd6d4 | 330 | |
| robinmc | 3:4b254b4bd6d4 | 331 | //******************************************************************* |
| robinmc | 3:4b254b4bd6d4 | 332 | |
| robinmc | 3:4b254b4bd6d4 | 333 | //*******************SD CARD & FILE MANAGEMENT*********************** |
| robinmc | 3:4b254b4bd6d4 | 334 | /**Reads the Pregress file on the SD card*/ |
| robinmc | 3:4b254b4bd6d4 | 335 | void readSD_progress(); |
| robinmc | 3:4b254b4bd6d4 | 336 | |
| robinmc | 3:4b254b4bd6d4 | 337 | /**Writes the current game progress onto the Progress file on the SD card*/ |
| robinmc | 3:4b254b4bd6d4 | 338 | void writeSD_progress(); |
| robinmc | 3:4b254b4bd6d4 | 339 | |
| robinmc | 3:4b254b4bd6d4 | 340 | /**Reads the Highscores file on the SD card and prints the 5 highest numbers in the Highscores array on the lcd screen*/ |
| robinmc | 3:4b254b4bd6d4 | 341 | void readSD_and_print_top_score(); |
| robinmc | 3:4b254b4bd6d4 | 342 | |
| robinmc | 3:4b254b4bd6d4 | 343 | /**Writes the topscore on the 6th position in the Highscores array (so it doesn't overwrite any values that are already stored)*/ |
| robinmc | 3:4b254b4bd6d4 | 344 | void writeSD(); |
| robinmc | 3:4b254b4bd6d4 | 345 | |
| robinmc | 3:4b254b4bd6d4 | 346 | ///Sorts the values and orders them in descending order |
| robinmc | 3:4b254b4bd6d4 | 347 | void sort_top_scores(); |
| robinmc | 3:4b254b4bd6d4 | 348 | |
| robinmc | 3:4b254b4bd6d4 | 349 | /**Funtion to delete a file |
| robinmc | 3:4b254b4bd6d4 | 350 | @param filename[] - Name of file that is to be deleted*/ |
| robinmc | 3:4b254b4bd6d4 | 351 | void delete_file(char filename[]); |
| robinmc | 3:4b254b4bd6d4 | 352 | |
| robinmc | 3:4b254b4bd6d4 | 353 | ///Delete the Highscores file |
| robinmc | 3:4b254b4bd6d4 | 354 | void Delete_Highscores(); |
| robinmc | 3:4b254b4bd6d4 | 355 | |
| robinmc | 3:4b254b4bd6d4 | 356 | //***************************************************************** |
| robinmc | 3:4b254b4bd6d4 | 357 | |
| robinmc | 3:4b254b4bd6d4 | 358 | //************************PRINTING ON LCD************************** |
| robinmc | 3:4b254b4bd6d4 | 359 | ///Prints the name of the game for 3 seconds when it's turned on |
| robinmc | 3:4b254b4bd6d4 | 360 | void intro(); |
| robinmc | 3:4b254b4bd6d4 | 361 | |
| robinmc | 3:4b254b4bd6d4 | 362 | ///Prints the credits on the LCD |
| robinmc | 3:4b254b4bd6d4 | 363 | void Credits(); |
| robinmc | 3:4b254b4bd6d4 | 364 | |
| robinmc | 3:4b254b4bd6d4 | 365 | ///Prints the floor on the LCD |
| robinmc | 3:4b254b4bd6d4 | 366 | void ground(); |
| robinmc | 3:4b254b4bd6d4 | 367 | |
| robinmc | 3:4b254b4bd6d4 | 368 | ///Prints the g_heart array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 369 | void print_heart(); |
| robinmc | 3:4b254b4bd6d4 | 370 | |
| robinmc | 3:4b254b4bd6d4 | 371 | ///Prints the g_ammo_pickUP on the LCD |
| robinmc | 3:4b254b4bd6d4 | 372 | void print_ammo_pickUp(); |
| robinmc | 3:4b254b4bd6d4 | 373 | |
| robinmc | 3:4b254b4bd6d4 | 374 | ///Prints the g_speed_boost on the LCD |
| robinmc | 3:4b254b4bd6d4 | 375 | void print_speed_boost(); |
| robinmc | 3:4b254b4bd6d4 | 376 | |
| robinmc | 3:4b254b4bd6d4 | 377 | ///Prints Recks (main character), the g_recks_still_gun array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 378 | void print_recks_still_gun(); |
| robinmc | 3:4b254b4bd6d4 | 379 | |
| robinmc | 3:4b254b4bd6d4 | 380 | ///Prints the g_recks_moving_gun array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 381 | void print_recks_moving_gun(); |
| robinmc | 3:4b254b4bd6d4 | 382 | |
| robinmc | 3:4b254b4bd6d4 | 383 | ///Prints the g_recks_crouch_gun array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 384 | void print_recks_crouch_gun(); |
| robinmc | 3:4b254b4bd6d4 | 385 | |
| robinmc | 3:4b254b4bd6d4 | 386 | ///Prints the g_recks_shield array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 387 | void print_recks_shield(); |
| robinmc | 3:4b254b4bd6d4 | 388 | |
| robinmc | 3:4b254b4bd6d4 | 389 | ///Prints the g_recks_jump_gun array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 390 | void print_recks_jump_gun(); |
| robinmc | 3:4b254b4bd6d4 | 391 | |
| robinmc | 3:4b254b4bd6d4 | 392 | ///Prints the g_recks_falling array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 393 | void print_recks_falling(); |
| robinmc | 3:4b254b4bd6d4 | 394 | |
| robinmc | 3:4b254b4bd6d4 | 395 | ///Prints the g_mob_rat_p1 (position 1) array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 396 | void print_mob_rat_p1(); |
| robinmc | 3:4b254b4bd6d4 | 397 | |
| robinmc | 3:4b254b4bd6d4 | 398 | ///Prints the g_mob_rat_p2 (position 2) array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 399 | void print_mob_rat_p2(); |
| robinmc | 3:4b254b4bd6d4 | 400 | |
| robinmc | 3:4b254b4bd6d4 | 401 | ///Prints the g_mob_hound_p1 (position 1) array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 402 | void print_mob_hound_p1(); |
| robinmc | 3:4b254b4bd6d4 | 403 | |
| robinmc | 3:4b254b4bd6d4 | 404 | ///Prints the g_mob_hound_p2 (position 2) array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 405 | void print_mob_hound_p2(); |
| robinmc | 3:4b254b4bd6d4 | 406 | |
| robinmc | 3:4b254b4bd6d4 | 407 | ///Prints the g_mob_hound_dead array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 408 | void print_mob_hound_dead(); |
| robinmc | 3:4b254b4bd6d4 | 409 | |
| robinmc | 3:4b254b4bd6d4 | 410 | ///Prints the g_mob_bear_p1 (position 1) array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 411 | void print_mob_bear_p1(); |
| robinmc | 3:4b254b4bd6d4 | 412 | |
| robinmc | 3:4b254b4bd6d4 | 413 | ///Prints the g_mob_bear_p2 (position 2) array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 414 | void print_mob_bear_p2(); |
| robinmc | 3:4b254b4bd6d4 | 415 | |
| robinmc | 3:4b254b4bd6d4 | 416 | ///Prints the g_mob_bear_dead array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 417 | void print_mob_bear_dead(); |
| robinmc | 3:4b254b4bd6d4 | 418 | |
| robinmc | 3:4b254b4bd6d4 | 419 | ///Prints the g_mob_bird_p1 (position 1) array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 420 | void print_mob_bird_p1(); |
| robinmc | 3:4b254b4bd6d4 | 421 | |
| robinmc | 3:4b254b4bd6d4 | 422 | ///Prints the g_mob_bird_p2 (position 2) array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 423 | void print_mob_bird_p2(); |
| robinmc | 3:4b254b4bd6d4 | 424 | |
| robinmc | 3:4b254b4bd6d4 | 425 | ///Prints the g_mob_bear_dead array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 426 | void print_mob_bird_dead(); |
| robinmc | 3:4b254b4bd6d4 | 427 | |
| robinmc | 3:4b254b4bd6d4 | 428 | ///Prints the cactus array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 429 | void print_cactus(); |
| robinmc | 3:4b254b4bd6d4 | 430 | |
| robinmc | 3:4b254b4bd6d4 | 431 | ///Prints the g_t_rex array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 432 | void print_t_rex(); |
| robinmc | 3:4b254b4bd6d4 | 433 | |
| robinmc | 3:4b254b4bd6d4 | 434 | ///Prints the g_t_rex_moving array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 435 | void print_t_rex_moving(); |
| robinmc | 3:4b254b4bd6d4 | 436 | |
| robinmc | 3:4b254b4bd6d4 | 437 | ///Prints the g_t_rex_attack array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 438 | void print_t_rex_attack(); |
| robinmc | 3:4b254b4bd6d4 | 439 | |
| robinmc | 3:4b254b4bd6d4 | 440 | ///Prints the g_fire_ball_p1 (position 1) array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 441 | void print_fire_ball_p1(); |
| robinmc | 3:4b254b4bd6d4 | 442 | |
| robinmc | 3:4b254b4bd6d4 | 443 | ///Prints the g_fire_ball_p2 (position 2) array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 444 | void print_fire_ball_p2(); |
| robinmc | 3:4b254b4bd6d4 | 445 | |
| robinmc | 3:4b254b4bd6d4 | 446 | ///Prints the g_clouds array on the LCD |
| robinmc | 3:4b254b4bd6d4 | 447 | void print_clouds(); |
| robinmc | 3:4b254b4bd6d4 | 448 | |
| robinmc | 3:4b254b4bd6d4 | 449 | /**Prints the g_clouds array on the LCD. It prints it multiple times next to the |
| robinmc | 3:4b254b4bd6d4 | 450 | corresponding chapter. They are either locked or unlocked depending on the |
| robinmc | 3:4b254b4bd6d4 | 451 | story_progress value*/ |
| robinmc | 3:4b254b4bd6d4 | 452 | void print_locks(); |
| robinmc | 3:4b254b4bd6d4 | 453 | |
| robinmc | 3:4b254b4bd6d4 | 454 | /// Prints a line of lengh 16 one pixel above the ground |
| robinmc | 3:4b254b4bd6d4 | 455 | void print_quick_sand(); |
| robinmc | 3:4b254b4bd6d4 | 456 | |
| robinmc | 3:4b254b4bd6d4 | 457 | /// Prints animation of Recks sinking in quick sand |
| robinmc | 3:4b254b4bd6d4 | 458 | void falling_animation(); |
| robinmc | 3:4b254b4bd6d4 | 459 | |
| robinmc | 3:4b254b4bd6d4 | 460 | ///Prints "SCORE" and the current score value on the top left of the LCD screen |
| robinmc | 3:4b254b4bd6d4 | 461 | void print_score(); |
| robinmc | 3:4b254b4bd6d4 | 462 | |
| robinmc | 3:4b254b4bd6d4 | 463 | ///Pritns "AMMO" and the remaining ammo on the top right of the LCD screen |
| robinmc | 3:4b254b4bd6d4 | 464 | void print_ammo(); |
| robinmc | 3:4b254b4bd6d4 | 465 | //*************************************************************** |
| robinmc | 3:4b254b4bd6d4 | 466 | |
| robinmc | 3:4b254b4bd6d4 | 467 | //******************************MENU'S*************************** |
| robinmc | 3:4b254b4bd6d4 | 468 | /**Funtion that pritns the main menu options and allows the user to select |
| robinmc | 3:4b254b4bd6d4 | 469 | one of the options by pressing the button A. */ |
| robinmc | 3:4b254b4bd6d4 | 470 | void main_menu(); |
| robinmc | 3:4b254b4bd6d4 | 471 | |
| robinmc | 3:4b254b4bd6d4 | 472 | /**Funtion that pritns the story mode menu options and allows the user to select |
| robinmc | 3:4b254b4bd6d4 | 473 | one of the chapters by pressing the button A or returning to the main menu by |
| robinmc | 3:4b254b4bd6d4 | 474 | pressing the button B. */ |
| robinmc | 3:4b254b4bd6d4 | 475 | void Story_Mode(); |
| robinmc | 3:4b254b4bd6d4 | 476 | |
| robinmc | 3:4b254b4bd6d4 | 477 | /**Funtion that pritns the settings menu options and allows the user to select |
| robinmc | 3:4b254b4bd6d4 | 478 | one of the options by pressing the button A or returning to the main menu by |
| robinmc | 3:4b254b4bd6d4 | 479 | pressing the button B. */ |
| robinmc | 3:4b254b4bd6d4 | 480 | void Settings(); |
| robinmc | 3:4b254b4bd6d4 | 481 | |
| robinmc | 3:4b254b4bd6d4 | 482 | /**Funtion that pritns the brightness menu options and allows the user to select |
| robinmc | 3:4b254b4bd6d4 | 483 | one of the different brightnesses by pressing the button A or returning to the |
| robinmc | 3:4b254b4bd6d4 | 484 | main menu by pressing the button B. */ |
| robinmc | 3:4b254b4bd6d4 | 485 | void Brightness(); |
| robinmc | 3:4b254b4bd6d4 | 486 | |
| robinmc | 3:4b254b4bd6d4 | 487 | /**Funtion that pritns the difficulty menu options and allows the user to select |
| robinmc | 3:4b254b4bd6d4 | 488 | one of the different difficulties by pressing the button A or returning to the |
| robinmc | 3:4b254b4bd6d4 | 489 | main menu by pressing the button B. */ |
| robinmc | 3:4b254b4bd6d4 | 490 | void Difficulty(); |
| robinmc | 3:4b254b4bd6d4 | 491 | |
| robinmc | 3:4b254b4bd6d4 | 492 | /**Funtion that allows the user to view the highscores and returning to the main |
| robinmc | 3:4b254b4bd6d4 | 493 | menu by pressing the button B. */ |
| robinmc | 3:4b254b4bd6d4 | 494 | void Leaderboard(); |
| robinmc | 3:4b254b4bd6d4 | 495 | |
| robinmc | 3:4b254b4bd6d4 | 496 | /**Funtion that pritns the guns options and allows the user to select |
| robinmc | 3:4b254b4bd6d4 | 497 | one of the different guns by pressing the button A or returning to the |
| robinmc | 3:4b254b4bd6d4 | 498 | main menu by pressing the button B. */ |
| robinmc | 3:4b254b4bd6d4 | 499 | void guns(); |
| robinmc | 3:4b254b4bd6d4 | 500 | //**************************************************************** |
| robinmc | 3:4b254b4bd6d4 | 501 | |
| robinmc | 3:4b254b4bd6d4 | 502 | //***************************GAME PHYSICS************************* |
| robinmc | 3:4b254b4bd6d4 | 503 | /**Funtion that contols the motion, physics and interations of Recks with the other |
| robinmc | 3:4b254b4bd6d4 | 504 | interactive elements*/ |
| robinmc | 3:4b254b4bd6d4 | 505 | void Recks(); |
| robinmc | 3:4b254b4bd6d4 | 506 | |
| robinmc | 3:4b254b4bd6d4 | 507 | /**Funtion that contols the motion, physics and interations of the rat with Recks*/ |
| robinmc | 3:4b254b4bd6d4 | 508 | void rat(); |
| robinmc | 3:4b254b4bd6d4 | 509 | |
| robinmc | 3:4b254b4bd6d4 | 510 | /**Funtion that contols the motion, physics and interations of the hound with Recks*/ |
| robinmc | 3:4b254b4bd6d4 | 511 | void hound(); |
| robinmc | 3:4b254b4bd6d4 | 512 | |
| robinmc | 3:4b254b4bd6d4 | 513 | /**Funtion that contols the motion, physics and interations of the bear with Recks*/ |
| robinmc | 3:4b254b4bd6d4 | 514 | void bear(); |
| robinmc | 3:4b254b4bd6d4 | 515 | |
| robinmc | 3:4b254b4bd6d4 | 516 | /**Funtion that contols the motion, physics and interations of the bird with Recks*/ |
| robinmc | 3:4b254b4bd6d4 | 517 | void bird(); |
| robinmc | 3:4b254b4bd6d4 | 518 | |
| robinmc | 3:4b254b4bd6d4 | 519 | /**Funtion that contols the motion, physics and interations of the cactus with Recks*/ |
| robinmc | 3:4b254b4bd6d4 | 520 | void cactus(); |
| robinmc | 3:4b254b4bd6d4 | 521 | |
| robinmc | 3:4b254b4bd6d4 | 522 | /**Funtion that contols the motion, physics and interations of the T Rex with Recks*/ |
| robinmc | 3:4b254b4bd6d4 | 523 | void t_rex(); |
| robinmc | 3:4b254b4bd6d4 | 524 | |
| robinmc | 3:4b254b4bd6d4 | 525 | /**Funtion that contols the motion, physics and interations of the fire ball with Recks*/ |
| robinmc | 3:4b254b4bd6d4 | 526 | void fire_ball(); |
| robinmc | 3:4b254b4bd6d4 | 527 | |
| robinmc | 3:4b254b4bd6d4 | 528 | /**Funtion that contols the motion, physics and interations of the quick sand with Recks*/ |
| robinmc | 3:4b254b4bd6d4 | 529 | void quick_sand(); |
| robinmc | 3:4b254b4bd6d4 | 530 | |
| robinmc | 3:4b254b4bd6d4 | 531 | /**Funtion that contols the motion, physics and interations of the heart pickup with Recks*/ |
| robinmc | 3:4b254b4bd6d4 | 532 | void heart(); |
| robinmc | 3:4b254b4bd6d4 | 533 | |
| robinmc | 3:4b254b4bd6d4 | 534 | /**Funtion that contols the motion, physics and interations of the ammo pickup with Recks*/ |
| robinmc | 3:4b254b4bd6d4 | 535 | void pickUp_ammo(); |
| robinmc | 3:4b254b4bd6d4 | 536 | |
| robinmc | 3:4b254b4bd6d4 | 537 | /**Funtion that contols the motion, physics and interations of the speed boost with Recks*/ |
| robinmc | 3:4b254b4bd6d4 | 538 | void speed_boost(); |
| robinmc | 3:4b254b4bd6d4 | 539 | |
| robinmc | 3:4b254b4bd6d4 | 540 | /**Funtion that turns on the shield*/ |
| robinmc | 3:4b254b4bd6d4 | 541 | void shield(); |
| robinmc | 3:4b254b4bd6d4 | 542 | //**************************************************************** |
| robinmc | 3:4b254b4bd6d4 | 543 | |
| robinmc | 3:4b254b4bd6d4 | 544 | //***************************GAME MODES*************************** |
| robinmc | 3:4b254b4bd6d4 | 545 | /**This funtion sets flags for printing interactive elements, depending on the difficulty |
| robinmc | 3:4b254b4bd6d4 | 546 | leavel selected*/ |
| robinmc | 3:4b254b4bd6d4 | 547 | void set_difficulty(); |
| robinmc | 3:4b254b4bd6d4 | 548 | |
| robinmc | 3:4b254b4bd6d4 | 549 | /**Funtion that runs the game*/ |
| robinmc | 3:4b254b4bd6d4 | 550 | void Game(); |
| robinmc | 3:4b254b4bd6d4 | 551 | |
| robinmc | 3:4b254b4bd6d4 | 552 | /**Funtion that runs the game without the sory mode*/ |
| robinmc | 3:4b254b4bd6d4 | 553 | void Minigame(); |
| robinmc | 3:4b254b4bd6d4 | 554 | |
| robinmc | 3:4b254b4bd6d4 | 555 | /**Funtion that prints sequential text introducing the game, and the game funtions*/ |
| robinmc | 3:4b254b4bd6d4 | 556 | void Tutorial(); |
| robinmc | 3:4b254b4bd6d4 | 557 | |
| robinmc | 3:4b254b4bd6d4 | 558 | /**Funtion that prints sequential text introducing the story and then runs the game |
| robinmc | 3:4b254b4bd6d4 | 559 | on a easy difficulty setting*/ |
| robinmc | 3:4b254b4bd6d4 | 560 | void Chapter1(); |
| robinmc | 3:4b254b4bd6d4 | 561 | |
| robinmc | 3:4b254b4bd6d4 | 562 | /**Funtion that prints sequential text expanding the story and then runs the game |
| robinmc | 3:4b254b4bd6d4 | 563 | on a increased difficulty setting*/ |
| robinmc | 3:4b254b4bd6d4 | 564 | void Chapter2(); |
| robinmc | 3:4b254b4bd6d4 | 565 | |
| robinmc | 3:4b254b4bd6d4 | 566 | /**Funtion that prints sequential text expanding the story and then runs the game |
| robinmc | 3:4b254b4bd6d4 | 567 | on a increased difficulty setting*/ |
| robinmc | 3:4b254b4bd6d4 | 568 | void Chapter3(); |
| robinmc | 3:4b254b4bd6d4 | 569 | |
| robinmc | 3:4b254b4bd6d4 | 570 | /**Funtion that prints sequential text expanding the story and then runs the game |
| robinmc | 3:4b254b4bd6d4 | 571 | with a final boss fight*/ |
| robinmc | 3:4b254b4bd6d4 | 572 | void Chapter4(); |
| robinmc | 3:4b254b4bd6d4 | 573 | |
| robinmc | 3:4b254b4bd6d4 | 574 | /**Funtion that runs when the lives global variable is 0. Printing a game over message |
| robinmc | 3:4b254b4bd6d4 | 575 | @returns 0 or 1. 0 returns back to the main menu and 1 re-plays the game after initializing values |
| robinmc | 3:4b254b4bd6d4 | 576 | */ |
| robinmc | 3:4b254b4bd6d4 | 577 | int Game_over(); |
| robinmc | 3:4b254b4bd6d4 | 578 | |
| robinmc | 3:4b254b4bd6d4 | 579 | /**Funtion that stops the game and powers down the LED's until the joystick button is pressed*/ |
| robinmc | 3:4b254b4bd6d4 | 580 | void Pause(); |
| robinmc | 3:4b254b4bd6d4 | 581 | //***************************************************************** |
| robinmc | 3:4b254b4bd6d4 | 582 | |
| robinmc | 3:4b254b4bd6d4 | 583 | |
| robinmc | 3:4b254b4bd6d4 | 584 |