Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
MenuClasses/StartScreen/StartScreen.h@76:7fa91122907f, 2019-05-05 (annotated)
- Committer:
- AhmedPlaymaker
- Date:
- Sun May 05 15:00:34 2019 +0000
- Revision:
- 76:7fa91122907f
- Parent:
- 67:39b9ba6019b0
- Child:
- 83:329da564799a
Fixed a problem i did not know i had about block sides collision, where i added the x axis coordinates of the block to the collision loop.
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 | 3:fbb1fa853f09 | 12 | class StartScreen |
AhmedPlaymaker | 3:fbb1fa853f09 | 13 | { |
AhmedPlaymaker | 67:39b9ba6019b0 | 14 | public: |
AhmedPlaymaker | 67:39b9ba6019b0 | 15 | |
AhmedPlaymaker | 3:fbb1fa853f09 | 16 | StartScreen(); |
AhmedPlaymaker | 65:2872ca289b49 | 17 | ~StartScreen(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 18 | |
AhmedPlaymaker | 3:fbb1fa853f09 | 19 | /** Initialise StartScreen |
AhmedPlaymaker | 3:fbb1fa853f09 | 20 | * |
AhmedPlaymaker | 3:fbb1fa853f09 | 21 | * This function initialises the Game Interface and restarts the display. |
AhmedPlaymaker | 3:fbb1fa853f09 | 22 | */ |
AhmedPlaymaker | 33:249cf423fb18 | 23 | void init(); |
AhmedPlaymaker | 67:39b9ba6019b0 | 24 | |
AhmedPlaymaker | 3:fbb1fa853f09 | 25 | /** Draw |
AhmedPlaymaker | 3:fbb1fa853f09 | 26 | * |
AhmedPlaymaker | 3:fbb1fa853f09 | 27 | * This function draws the Sprite onto the screen. |
AhmedPlaymaker | 3:fbb1fa853f09 | 28 | */ |
AhmedPlaymaker | 66:e47333ffc6ca | 29 | void titleScreen(N5110 &lcd, Gamepad &pad); |
AhmedPlaymaker | 67:39b9ba6019b0 | 30 | |
AhmedPlaymaker | 3:fbb1fa853f09 | 31 | /** Instruct |
AhmedPlaymaker | 3:fbb1fa853f09 | 32 | * |
AhmedPlaymaker | 3:fbb1fa853f09 | 33 | * This function updates the user about how to progress after the game banner has been displayed.. |
AhmedPlaymaker | 3:fbb1fa853f09 | 34 | */ |
AhmedPlaymaker | 33:249cf423fb18 | 35 | void instruct(N5110 &lcd, Gamepad &pad); |
AhmedPlaymaker | 67:39b9ba6019b0 | 36 | |
AhmedPlaymaker | 3:fbb1fa853f09 | 37 | /** Display userID |
AhmedPlaymaker | 3:fbb1fa853f09 | 38 | * |
AhmedPlaymaker | 3:fbb1fa853f09 | 39 | * This function shows who the author of the game is before showing the menu screen. |
AhmedPlaymaker | 3:fbb1fa853f09 | 40 | */ |
AhmedPlaymaker | 49:441c32f6603e | 41 | void credits(N5110 &lcd); |
AhmedPlaymaker | 67:39b9ba6019b0 | 42 | |
AhmedPlaymaker | 49:441c32f6603e | 43 | /** Read Stats |
AhmedPlaymaker | 49:441c32f6603e | 44 | * |
AhmedPlaymaker | 49:441c32f6603e | 45 | * This function just reads the current top level stored in the sd card and saves it for displaying in the menu. |
AhmedPlaymaker | 49:441c32f6603e | 46 | */ |
AhmedPlaymaker | 49:441c32f6603e | 47 | void read_stats(SDFileSystem &sd); |
AhmedPlaymaker | 67:39b9ba6019b0 | 48 | |
AhmedPlaymaker | 66:e47333ffc6ca | 49 | /** Check Back Pressed |
AhmedPlaymaker | 66:e47333ffc6ca | 50 | * |
AhmedPlaymaker | 66:e47333ffc6ca | 51 | * This function makes a centralised approach to check when back is pressed in a loop, so that it can be used to exit it and also go to. |
AhmedPlaymaker | 66:e47333ffc6ca | 52 | * the previous menu option. |
AhmedPlaymaker | 66:e47333ffc6ca | 53 | */ |
AhmedPlaymaker | 66:e47333ffc6ca | 54 | bool checkBackPressed(Gamepad &pad); |
AhmedPlaymaker | 67:39b9ba6019b0 | 55 | |
AhmedPlaymaker | 66:e47333ffc6ca | 56 | /** The Menu Screen |
AhmedPlaymaker | 3:fbb1fa853f09 | 57 | * |
AhmedPlaymaker | 3:fbb1fa853f09 | 58 | * This function obtains the user input on how they want to progress. |
AhmedPlaymaker | 3:fbb1fa853f09 | 59 | */ |
AhmedPlaymaker | 67:39b9ba6019b0 | 60 | void menu(N5110 &lcd, Gamepad &pad); |
AhmedPlaymaker | 67:39b9ba6019b0 | 61 | |
AhmedPlaymaker | 66:e47333ffc6ca | 62 | /** Main Menu |
AhmedPlaymaker | 30:461231877c89 | 63 | * |
AhmedPlaymaker | 66:e47333ffc6ca | 64 | * This function displays all the Main Menu contents to the player. |
AhmedPlaymaker | 30:461231877c89 | 65 | */ |
AhmedPlaymaker | 66:e47333ffc6ca | 66 | void mainMenu(N5110 &lcd, Gamepad &pad); |
AhmedPlaymaker | 67:39b9ba6019b0 | 67 | |
AhmedPlaymaker | 67:39b9ba6019b0 | 68 | /** Draw Selection Arrow |
AhmedPlaymaker | 67:39b9ba6019b0 | 69 | * |
AhmedPlaymaker | 67:39b9ba6019b0 | 70 | * This function draws arrow to select main menu options. |
AhmedPlaymaker | 67:39b9ba6019b0 | 71 | */ |
AhmedPlaymaker | 67:39b9ba6019b0 | 72 | void drawSelectionArrow(N5110 &lcd, Gamepad &pad); |
AhmedPlaymaker | 67:39b9ba6019b0 | 73 | |
AhmedPlaymaker | 34:89f53ffc81bb | 74 | /** Implementing The First Menu Screen |
AhmedPlaymaker | 34:89f53ffc81bb | 75 | * |
AhmedPlaymaker | 34:89f53ffc81bb | 76 | * This function just implements the things decided in main menu. |
AhmedPlaymaker | 34:89f53ffc81bb | 77 | */ |
AhmedPlaymaker | 66:e47333ffc6ca | 78 | void nextMenu(N5110 &lcd, Gamepad &pad); |
AhmedPlaymaker | 33:249cf423fb18 | 79 | |
AhmedPlaymaker | 4:1fe015b66bb8 | 80 | /** The Second Menu Screen |
AhmedPlaymaker | 4:1fe015b66bb8 | 81 | * |
AhmedPlaymaker | 4:1fe015b66bb8 | 82 | * This function obtains the user input on the game type they would like to play. |
AhmedPlaymaker | 4:1fe015b66bb8 | 83 | */ |
AhmedPlaymaker | 49:441c32f6603e | 84 | void game_mode(N5110 &lcd, Gamepad &pad); |
AhmedPlaymaker | 67:39b9ba6019b0 | 85 | |
AhmedPlaymaker | 56:142e9fdb77a8 | 86 | /** Displaying Mode Options |
AhmedPlaymaker | 42:973bb6036f81 | 87 | * |
AhmedPlaymaker | 56:142e9fdb77a8 | 88 | * This function displays game_mode contents. |
AhmedPlaymaker | 42:973bb6036f81 | 89 | */ |
AhmedPlaymaker | 76:7fa91122907f | 90 | void selectMode(N5110 &lcd, Gamepad &pad); |
AhmedPlaymaker | 67:39b9ba6019b0 | 91 | |
AhmedPlaymaker | 56:142e9fdb77a8 | 92 | /** Selecting the game mode |
AhmedPlaymaker | 34:89f53ffc81bb | 93 | * |
AhmedPlaymaker | 56:142e9fdb77a8 | 94 | * value of g_mode is changed in this function that allows the choise beteen joystick/motion control.. |
AhmedPlaymaker | 34:89f53ffc81bb | 95 | */ |
AhmedPlaymaker | 76:7fa91122907f | 96 | void scrollModeSelection(Gamepad &pad); |
AhmedPlaymaker | 67:39b9ba6019b0 | 97 | |
AhmedPlaymaker | 58:affb42c56cf8 | 98 | /** Motion Control Instructions |
AhmedPlaymaker | 58:affb42c56cf8 | 99 | * |
AhmedPlaymaker | 58:affb42c56cf8 | 100 | * This promts the user to press A to centre position their angle if Motion Control is selected.. |
AhmedPlaymaker | 58:affb42c56cf8 | 101 | */ |
AhmedPlaymaker | 58:affb42c56cf8 | 102 | void motionControlInstructions(N5110 &lcd); |
AhmedPlaymaker | 67:39b9ba6019b0 | 103 | |
AhmedPlaymaker | 4:1fe015b66bb8 | 104 | /** The Third Menu Screen |
AhmedPlaymaker | 4:1fe015b66bb8 | 105 | * |
AhmedPlaymaker | 4:1fe015b66bb8 | 106 | * This function obtains the user input on the game speed that suits them. |
AhmedPlaymaker | 4:1fe015b66bb8 | 107 | */ |
AhmedPlaymaker | 49:441c32f6603e | 108 | void game_speed(N5110 &lcd, Gamepad &pad); |
AhmedPlaymaker | 76:7fa91122907f | 109 | |
AhmedPlaymaker | 76:7fa91122907f | 110 | /** Displaying GAME speed Contents |
AhmedPlaymaker | 76:7fa91122907f | 111 | * |
AhmedPlaymaker | 76:7fa91122907f | 112 | * This function just displays game_speed contents. |
AhmedPlaymaker | 76:7fa91122907f | 113 | */ |
AhmedPlaymaker | 76:7fa91122907f | 114 | void selectSpeed(N5110 &lcd, Gamepad &pad); |
AhmedPlaymaker | 67:39b9ba6019b0 | 115 | |
AhmedPlaymaker | 35:ce47cde57bd3 | 116 | /** Implementing GS |
AhmedPlaymaker | 35:ce47cde57bd3 | 117 | * |
AhmedPlaymaker | 35:ce47cde57bd3 | 118 | * This function just decides what has to be done next. |
AhmedPlaymaker | 35:ce47cde57bd3 | 119 | */ |
AhmedPlaymaker | 76:7fa91122907f | 120 | void scrollSpeedSelection(Gamepad &pad); |
AhmedPlaymaker | 67:39b9ba6019b0 | 121 | |
AhmedPlaymaker | 67:39b9ba6019b0 | 122 | |
AhmedPlaymaker | 65:2872ca289b49 | 123 | //SETTING THE GAME SPEED AND GAME MODE. |
AhmedPlaymaker | 65:2872ca289b49 | 124 | int fps; // this sends over the game speed |
AhmedPlaymaker | 65:2872ca289b49 | 125 | int g_mode; //this helps to select between joystick and motion control. |
AhmedPlaymaker | 67:39b9ba6019b0 | 126 | int speed_index; |
AhmedPlaymaker | 67:39b9ba6019b0 | 127 | |
AhmedPlaymaker | 65:2872ca289b49 | 128 | //MENU OPTIONS INDEX. |
AhmedPlaymaker | 67:39b9ba6019b0 | 129 | int menu_index; |
AhmedPlaymaker | 67:39b9ba6019b0 | 130 | |
AhmedPlaymaker | 65:2872ca289b49 | 131 | //VARIABLE USED TO DECIDE WEATHER TO SHOW CREDITS. |
AhmedPlaymaker | 65:2872ca289b49 | 132 | int showCredits; |
AhmedPlaymaker | 67:39b9ba6019b0 | 133 | |
AhmedPlaymaker | 65:2872ca289b49 | 134 | //VARIABLE USED TO DECIDE THE WAIT TIME OF THE MENU PAGES. |
AhmedPlaymaker | 65:2872ca289b49 | 135 | float controlSensitivity; |
AhmedPlaymaker | 67:39b9ba6019b0 | 136 | |
AhmedPlaymaker | 65:2872ca289b49 | 137 | //VARIABLES TO TOGGLE BACK AND FORTH BETWEEN MENU OPTIONS. |
AhmedPlaymaker | 66:e47333ffc6ca | 138 | bool _backPressed; //remembers if back is pressed. |
AhmedPlaymaker | 66:e47333ffc6ca | 139 | bool _startPressed; //remembers if start is pressed. |
AhmedPlaymaker | 67:39b9ba6019b0 | 140 | |
AhmedPlaymaker | 67:39b9ba6019b0 | 141 | private: |
AhmedPlaymaker | 67:39b9ba6019b0 | 142 | |
AhmedPlaymaker | 65:2872ca289b49 | 143 | //OBJECT DECLARATIONS |
AhmedPlaymaker | 33:249cf423fb18 | 144 | Stats _stats; |
AhmedPlaymaker | 60:d3a9e0e4a0de | 145 | Settings _settings; |
AhmedPlaymaker | 60:d3a9e0e4a0de | 146 | Tutorial _tutorial; |
AhmedPlaymaker | 3:fbb1fa853f09 | 147 | |
AhmedPlaymaker | 67:39b9ba6019b0 | 148 | |
AhmedPlaymaker | 3:fbb1fa853f09 | 149 | |
AhmedPlaymaker | 3:fbb1fa853f09 | 150 | }; |
AhmedPlaymaker | 3:fbb1fa853f09 | 151 | #endif |