Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Committer:
AhmedPlaymaker
Date:
Mon May 06 16:15:21 2019 +0000
Revision:
84:9950d561fdf8
Parent:
83:329da564799a
Child:
88:1e2e70a484e7
Added some more comments to describe what some of my functions and methods do.

Who changed what in which revision?

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