Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
MenuClasses/StartScreen/StartScreen.h@104:17040265b7b4, 2019-05-09 (annotated)
- Committer:
- AhmedPlaymaker
- Date:
- Thu May 09 14:52:19 2019 +0000
- Revision:
- 104:17040265b7b4
- Parent:
- 92:693a6ae0ff8e
Final Submission. I have read and agreed with Statement of Academic Integrity.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AhmedPlaymaker | 3:fbb1fa853f09 | 1 | #ifndef StartScreen_H |
AhmedPlaymaker | 3:fbb1fa853f09 | 2 | #define StartScreen_H |
AhmedPlaymaker | 3:fbb1fa853f09 | 3 | |
AhmedPlaymaker | 3:fbb1fa853f09 | 4 | #include "mbed.h" |
AhmedPlaymaker | 3:fbb1fa853f09 | 5 | #include "N5110.h" |
AhmedPlaymaker | 3:fbb1fa853f09 | 6 | #include "Gamepad.h" |
AhmedPlaymaker | 5:e4df87957a5b | 7 | #include "Settings.h" |
AhmedPlaymaker | 33:249cf423fb18 | 8 | #include "Stats.h" |
AhmedPlaymaker | 33:249cf423fb18 | 9 | #include "SDFileSystem.h" |
AhmedPlaymaker | 60:d3a9e0e4a0de | 10 | #include "Tutorial.h" |
AhmedPlaymaker | 3:fbb1fa853f09 | 11 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 12 | /** StartScreen Class |
AhmedPlaymaker | 88:1e2e70a484e7 | 13 | @brief Class for displaying the menu, calling all the classes that follow the menu (eg: Settings) and the animation when the game starts. |
AhmedPlaymaker | 88:1e2e70a484e7 | 14 | @author Ahmed N.Adamjee |
AhmedPlaymaker | 88:1e2e70a484e7 | 15 | @date 8th May 2019 |
AhmedPlaymaker | 88:1e2e70a484e7 | 16 | */ |
AhmedPlaymaker | 3:fbb1fa853f09 | 17 | class StartScreen |
AhmedPlaymaker | 3:fbb1fa853f09 | 18 | { |
AhmedPlaymaker | 67:39b9ba6019b0 | 19 | public: |
AhmedPlaymaker | 67:39b9ba6019b0 | 20 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 21 | /** Constructor */ |
AhmedPlaymaker | 3:fbb1fa853f09 | 22 | StartScreen(); |
AhmedPlaymaker | 88:1e2e70a484e7 | 23 | /** Destructor */ |
AhmedPlaymaker | 65:2872ca289b49 | 24 | ~StartScreen(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 25 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 26 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 27 | * @brief Initialises all parameters of the Game Interface, assigns some default values and calls other init() functions. |
AhmedPlaymaker | 91:ca8cff78f2fe | 28 | * @param N5110 *lcd @details pointer to the N5110 object in main, address of this pointer is saved to make availability to the entire class, without passing address to each function. |
AhmedPlaymaker | 91:ca8cff78f2fe | 29 | * @param Gamepad *pad @details pointer to the gamepad object in main, address of this pointer is saved to make availability to the entire class, without passing address to each function. |
AhmedPlaymaker | 3:fbb1fa853f09 | 30 | */ |
AhmedPlaymaker | 83:329da564799a | 31 | void init(N5110 *lcd, Gamepad *pad); |
AhmedPlaymaker | 84:9950d561fdf8 | 32 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 33 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 34 | * @brief This function initialises the class objects that are the diffrent parts of the game (Eg: SnakeFood Class). |
AhmedPlaymaker | 91:ca8cff78f2fe | 35 | */ |
AhmedPlaymaker | 84:9950d561fdf8 | 36 | void object_initialisations(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 37 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 38 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 39 | * @brief Draws the Title Sprite onto the screen and plays theme song. |
AhmedPlaymaker | 91:ca8cff78f2fe | 40 | */ |
AhmedPlaymaker | 83:329da564799a | 41 | void titleScreen(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 42 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 43 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 44 | * @brief Instructs the user about how to progress after the title screen has been displayed. |
AhmedPlaymaker | 91:ca8cff78f2fe | 45 | */ |
AhmedPlaymaker | 83:329da564799a | 46 | void instruct(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 47 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 48 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 49 | * @brief Shows who the author of the game is before starting the game. This function's functionality can be hidden using settings. |
AhmedPlaymaker | 91:ca8cff78f2fe | 50 | */ |
AhmedPlaymaker | 83:329da564799a | 51 | void credits(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 52 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 53 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 54 | * @brief Reads stored statistics using the Stats class in the sd card and saves it for displaying in the menu. |
AhmedPlaymaker | 91:ca8cff78f2fe | 55 | *@param SDFileSystem &sd @details The SDFileSystem library. |
AhmedPlaymaker | 88:1e2e70a484e7 | 56 | @code |
AhmedPlaymaker | 88:1e2e70a484e7 | 57 | _stats.read(sd); |
AhmedPlaymaker | 88:1e2e70a484e7 | 58 | @endcode |
AhmedPlaymaker | 49:441c32f6603e | 59 | */ |
AhmedPlaymaker | 49:441c32f6603e | 60 | void read_stats(SDFileSystem &sd); |
AhmedPlaymaker | 67:39b9ba6019b0 | 61 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 62 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 63 | * @brief Checks BACK if button pressed in a loop, can be used to exit it and also remember if true/false and used for various conditions. |
AhmedPlaymaker | 92:693a6ae0ff8e | 64 | * @returns _backPressed @detalis True if the BACK pressed, else False. |
AhmedPlaymaker | 66:e47333ffc6ca | 65 | */ |
AhmedPlaymaker | 83:329da564799a | 66 | bool checkBackPressed(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 67 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 68 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 69 | * @brief Checks if START or A buttons are pressed in a loop, can be used to terminate it and also remember if true/false and used for various conditions. |
AhmedPlaymaker | 92:693a6ae0ff8e | 70 | * @returns _startPressed @details True if the START or A pressed, else False. |
AhmedPlaymaker | 84:9950d561fdf8 | 71 | */ |
AhmedPlaymaker | 84:9950d561fdf8 | 72 | bool checkStartorAPressed(); |
AhmedPlaymaker | 84:9950d561fdf8 | 73 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 74 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 75 | * @brief Waits for the user to select a menu option and calls a related function. |
AhmedPlaymaker | 91:ca8cff78f2fe | 76 | */ |
AhmedPlaymaker | 83:329da564799a | 77 | void menu(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 78 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 79 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 80 | * @brief Displays all the Main Menu contents to the player and allows the user to navigate using drawSelectionArrow(). |
AhmedPlaymaker | 91:ca8cff78f2fe | 81 | */ |
AhmedPlaymaker | 83:329da564799a | 82 | void mainMenu(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 83 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 84 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 85 | * @brief Draws an arrow to aid the selection of main menu options. |
AhmedPlaymaker | 91:ca8cff78f2fe | 86 | */ |
AhmedPlaymaker | 83:329da564799a | 87 | void drawSelectionArrow(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 88 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 89 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 90 | * @brief Calls the next menu item dependent on the input in mainMenu(). |
AhmedPlaymaker | 91:ca8cff78f2fe | 91 | */ |
AhmedPlaymaker | 83:329da564799a | 92 | void nextMenu(); |
AhmedPlaymaker | 33:249cf423fb18 | 93 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 94 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 95 | * @brief Obtains the user input on the game mode they would like to play on (Joystick or Motion Control). |
AhmedPlaymaker | 91:ca8cff78f2fe | 96 | */ |
AhmedPlaymaker | 83:329da564799a | 97 | void game_mode(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 98 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 99 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 100 | * @brief Value of g_mode is changed in this function that allows the choice between joystick/motion control. |
AhmedPlaymaker | 91:ca8cff78f2fe | 101 | */ |
AhmedPlaymaker | 83:329da564799a | 102 | void selectMode(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 103 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 104 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 105 | * @brief Changes the page displayed in the game mode menu |
AhmedPlaymaker | 91:ca8cff78f2fe | 106 | */ |
AhmedPlaymaker | 83:329da564799a | 107 | void scrollModeSelection(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 108 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 109 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 110 | * @brief Promts the user to press A to centre position their angle during the game if Motion Control is selected. |
AhmedPlaymaker | 91:ca8cff78f2fe | 111 | */ |
AhmedPlaymaker | 83:329da564799a | 112 | void motionControlInstructions(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 113 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 114 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 115 | * @brief Obtains the user input on the game speed to be used later in the SnakevsBlock class. |
AhmedPlaymaker | 91:ca8cff78f2fe | 116 | */ |
AhmedPlaymaker | 83:329da564799a | 117 | void game_speed(); |
AhmedPlaymaker | 84:9950d561fdf8 | 118 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 119 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 120 | * @brief Value of fps is changed in this function that will be used as frames per second in my game loop in main.cpp. |
AhmedPlaymaker | 91:ca8cff78f2fe | 121 | */ |
AhmedPlaymaker | 83:329da564799a | 122 | void selectSpeed(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 123 | |
AhmedPlaymaker | 91:ca8cff78f2fe | 124 | /** |
AhmedPlaymaker | 91:ca8cff78f2fe | 125 | * @brief Changes the page displayed in the game speed menu |
AhmedPlaymaker | 91:ca8cff78f2fe | 126 | */ |
AhmedPlaymaker | 83:329da564799a | 127 | void scrollSpeedSelection(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 128 | |
AhmedPlaymaker | 67:39b9ba6019b0 | 129 | |
AhmedPlaymaker | 65:2872ca289b49 | 130 | //SETTING THE GAME SPEED AND GAME MODE. |
AhmedPlaymaker | 65:2872ca289b49 | 131 | int fps; // this sends over the game speed |
AhmedPlaymaker | 65:2872ca289b49 | 132 | int g_mode; //this helps to select between joystick and motion control. |
AhmedPlaymaker | 67:39b9ba6019b0 | 133 | int speed_index; |
AhmedPlaymaker | 67:39b9ba6019b0 | 134 | |
AhmedPlaymaker | 65:2872ca289b49 | 135 | //MENU OPTIONS INDEX. |
AhmedPlaymaker | 67:39b9ba6019b0 | 136 | int menu_index; |
AhmedPlaymaker | 67:39b9ba6019b0 | 137 | |
AhmedPlaymaker | 65:2872ca289b49 | 138 | //VARIABLE USED TO DECIDE WEATHER TO SHOW CREDITS. |
AhmedPlaymaker | 65:2872ca289b49 | 139 | int showCredits; |
AhmedPlaymaker | 67:39b9ba6019b0 | 140 | |
AhmedPlaymaker | 65:2872ca289b49 | 141 | //VARIABLE USED TO DECIDE THE WAIT TIME OF THE MENU PAGES. |
AhmedPlaymaker | 65:2872ca289b49 | 142 | float controlSensitivity; |
AhmedPlaymaker | 67:39b9ba6019b0 | 143 | |
AhmedPlaymaker | 67:39b9ba6019b0 | 144 | private: |
AhmedPlaymaker | 67:39b9ba6019b0 | 145 | |
AhmedPlaymaker | 65:2872ca289b49 | 146 | //OBJECT DECLARATIONS |
AhmedPlaymaker | 33:249cf423fb18 | 147 | Stats _stats; |
AhmedPlaymaker | 60:d3a9e0e4a0de | 148 | Settings _settings; |
AhmedPlaymaker | 60:d3a9e0e4a0de | 149 | Tutorial _tutorial; |
AhmedPlaymaker | 88:1e2e70a484e7 | 150 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 151 | //VARIABLES TO TOGGLE BACK AND FORTH BETWEEN MENU OPTIONS. |
AhmedPlaymaker | 88:1e2e70a484e7 | 152 | bool _backPressed; //remembers if back is pressed. |
AhmedPlaymaker | 88:1e2e70a484e7 | 153 | bool _startPressed; //remembers if start is pressed. |
AhmedPlaymaker | 84:9950d561fdf8 | 154 | |
AhmedPlaymaker | 83:329da564799a | 155 | //Pointer to the game pad object pad. |
AhmedPlaymaker | 83:329da564799a | 156 | Gamepad *_pad; |
AhmedPlaymaker | 83:329da564799a | 157 | //Pointer to the N5110 object lcd. |
AhmedPlaymaker | 83:329da564799a | 158 | N5110 *_lcd; |
AhmedPlaymaker | 3:fbb1fa853f09 | 159 | |
AhmedPlaymaker | 67:39b9ba6019b0 | 160 | |
AhmedPlaymaker | 3:fbb1fa853f09 | 161 | |
AhmedPlaymaker | 3:fbb1fa853f09 | 162 | }; |
AhmedPlaymaker | 3:fbb1fa853f09 | 163 | #endif |