![](/media/cache/profiles/LinkedIn_0NghoZJ.jpeg.50x50_q85.jpg)
Snake vs Block Game to be run upon K64F.
MenuClasses/StartScreen/StartScreen.h@88:1e2e70a484e7, 2019-05-08 (annotated)
- Committer:
- AhmedPlaymaker
- Date:
- Wed May 08 18:20:23 2019 +0000
- Revision:
- 88:1e2e70a484e7
- Parent:
- 84:9950d561fdf8
- Child:
- 91:ca8cff78f2fe
Created the documentation for the startscreen class.
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 | 88:1e2e70a484e7 | 26 | /** Initialises all parameters of the Game Interface, assigns some default values and calls other init() functions. |
AhmedPlaymaker | 88:1e2e70a484e7 | 27 | * @param 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 | 88:1e2e70a484e7 | 28 | * @param 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 | 29 | */ |
AhmedPlaymaker | 83:329da564799a | 30 | void init(N5110 *lcd, Gamepad *pad); |
AhmedPlaymaker | 84:9950d561fdf8 | 31 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 32 | /**This function initialises the class objects that are the diffrent parts of the game (Eg: SnakeFood Class).*/ |
AhmedPlaymaker | 84:9950d561fdf8 | 33 | void object_initialisations(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 34 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 35 | /** Draws the Title Sprite onto the screen and plays theme song.*/ |
AhmedPlaymaker | 83:329da564799a | 36 | void titleScreen(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 37 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 38 | /** Instructs the user about how to progress after the title screen has been displayed.*/ |
AhmedPlaymaker | 83:329da564799a | 39 | void instruct(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 40 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 41 | /** Shows who the author of the game is before starting the game. This function's functionality can be hidden using settings.*/ |
AhmedPlaymaker | 83:329da564799a | 42 | void credits(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 43 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 44 | /** Reads stored statistics using the Stats class in the sd card and saves it for displaying in the menu. |
AhmedPlaymaker | 88:1e2e70a484e7 | 45 | *@param The SDFileSystem library |
AhmedPlaymaker | 88:1e2e70a484e7 | 46 | @code |
AhmedPlaymaker | 88:1e2e70a484e7 | 47 | _stats.read(sd); |
AhmedPlaymaker | 88:1e2e70a484e7 | 48 | @endcode |
AhmedPlaymaker | 49:441c32f6603e | 49 | */ |
AhmedPlaymaker | 49:441c32f6603e | 50 | void read_stats(SDFileSystem &sd); |
AhmedPlaymaker | 67:39b9ba6019b0 | 51 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 52 | /** 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 | 88:1e2e70a484e7 | 53 | * @return True if the BACK pressed, else False. |
AhmedPlaymaker | 66:e47333ffc6ca | 54 | */ |
AhmedPlaymaker | 83:329da564799a | 55 | bool checkBackPressed(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 56 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 57 | /** 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 | 88:1e2e70a484e7 | 58 | * @return True if the START or A pressed, else False. |
AhmedPlaymaker | 84:9950d561fdf8 | 59 | */ |
AhmedPlaymaker | 84:9950d561fdf8 | 60 | bool checkStartorAPressed(); |
AhmedPlaymaker | 84:9950d561fdf8 | 61 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 62 | /** Waits for the user to select a menu option and calls a related function*/ |
AhmedPlaymaker | 83:329da564799a | 63 | void menu(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 64 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 65 | /** Displays all the Main Menu contents to the player and allows the user to navigate using drawSelectionArrow().*/ |
AhmedPlaymaker | 83:329da564799a | 66 | void mainMenu(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 67 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 68 | /** Draws an arrow to aid the selection of main menu options.*/ |
AhmedPlaymaker | 83:329da564799a | 69 | void drawSelectionArrow(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 70 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 71 | /** Calls the next menu item dependent on the input in mainMenu().*/ |
AhmedPlaymaker | 83:329da564799a | 72 | void nextMenu(); |
AhmedPlaymaker | 33:249cf423fb18 | 73 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 74 | /** Obtains the user input on the game mode they would like to play on (Joystick or Motion Control).*/ |
AhmedPlaymaker | 83:329da564799a | 75 | void game_mode(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 76 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 77 | /** Value of g_mode is changed in this function that allows the choice between joystick/motion control.*/ |
AhmedPlaymaker | 83:329da564799a | 78 | void selectMode(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 79 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 80 | /** Changes the page displayed in the game mode menu*/ |
AhmedPlaymaker | 83:329da564799a | 81 | void scrollModeSelection(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 82 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 83 | /** Promts the user to press A to centre position their angle during the game if Motion Control is selected.*/ |
AhmedPlaymaker | 83:329da564799a | 84 | void motionControlInstructions(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 85 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 86 | /** Obtains the user input on the game speed to be used later in the SnakevsBlock class.*/ |
AhmedPlaymaker | 83:329da564799a | 87 | void game_speed(); |
AhmedPlaymaker | 84:9950d561fdf8 | 88 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 89 | /** Value of fps is changed in this function that will be used as frames per second in my game loop in main.cpp.*/ |
AhmedPlaymaker | 83:329da564799a | 90 | void selectSpeed(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 91 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 92 | /** Changes the page displayed in the game speed menu*/ |
AhmedPlaymaker | 83:329da564799a | 93 | void scrollSpeedSelection(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 94 | |
AhmedPlaymaker | 67:39b9ba6019b0 | 95 | |
AhmedPlaymaker | 65:2872ca289b49 | 96 | //SETTING THE GAME SPEED AND GAME MODE. |
AhmedPlaymaker | 65:2872ca289b49 | 97 | int fps; // this sends over the game speed |
AhmedPlaymaker | 65:2872ca289b49 | 98 | int g_mode; //this helps to select between joystick and motion control. |
AhmedPlaymaker | 67:39b9ba6019b0 | 99 | int speed_index; |
AhmedPlaymaker | 67:39b9ba6019b0 | 100 | |
AhmedPlaymaker | 65:2872ca289b49 | 101 | //MENU OPTIONS INDEX. |
AhmedPlaymaker | 67:39b9ba6019b0 | 102 | int menu_index; |
AhmedPlaymaker | 67:39b9ba6019b0 | 103 | |
AhmedPlaymaker | 65:2872ca289b49 | 104 | //VARIABLE USED TO DECIDE WEATHER TO SHOW CREDITS. |
AhmedPlaymaker | 65:2872ca289b49 | 105 | int showCredits; |
AhmedPlaymaker | 67:39b9ba6019b0 | 106 | |
AhmedPlaymaker | 65:2872ca289b49 | 107 | //VARIABLE USED TO DECIDE THE WAIT TIME OF THE MENU PAGES. |
AhmedPlaymaker | 65:2872ca289b49 | 108 | float controlSensitivity; |
AhmedPlaymaker | 67:39b9ba6019b0 | 109 | |
AhmedPlaymaker | 67:39b9ba6019b0 | 110 | private: |
AhmedPlaymaker | 67:39b9ba6019b0 | 111 | |
AhmedPlaymaker | 65:2872ca289b49 | 112 | //OBJECT DECLARATIONS |
AhmedPlaymaker | 33:249cf423fb18 | 113 | Stats _stats; |
AhmedPlaymaker | 60:d3a9e0e4a0de | 114 | Settings _settings; |
AhmedPlaymaker | 60:d3a9e0e4a0de | 115 | Tutorial _tutorial; |
AhmedPlaymaker | 88:1e2e70a484e7 | 116 | |
AhmedPlaymaker | 88:1e2e70a484e7 | 117 | //VARIABLES TO TOGGLE BACK AND FORTH BETWEEN MENU OPTIONS. |
AhmedPlaymaker | 88:1e2e70a484e7 | 118 | bool _backPressed; //remembers if back is pressed. |
AhmedPlaymaker | 88:1e2e70a484e7 | 119 | bool _startPressed; //remembers if start is pressed. |
AhmedPlaymaker | 84:9950d561fdf8 | 120 | |
AhmedPlaymaker | 83:329da564799a | 121 | //Pointer to the game pad object pad. |
AhmedPlaymaker | 83:329da564799a | 122 | Gamepad *_pad; |
AhmedPlaymaker | 83:329da564799a | 123 | //Pointer to the N5110 object lcd. |
AhmedPlaymaker | 83:329da564799a | 124 | N5110 *_lcd; |
AhmedPlaymaker | 3:fbb1fa853f09 | 125 | |
AhmedPlaymaker | 67:39b9ba6019b0 | 126 | |
AhmedPlaymaker | 3:fbb1fa853f09 | 127 | |
AhmedPlaymaker | 3:fbb1fa853f09 | 128 | }; |
AhmedPlaymaker | 3:fbb1fa853f09 | 129 | #endif |