Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Committer:
AhmedPlaymaker
Date:
Fri May 03 19:16:02 2019 +0000
Revision:
65:2872ca289b49
Parent:
60:d3a9e0e4a0de
Child:
66:e47333ffc6ca
Refactored some function into smaller ones

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 3:fbb1fa853f09 14 public:
AhmedPlaymaker 3:fbb1fa853f09 15
AhmedPlaymaker 3:fbb1fa853f09 16 StartScreen();
AhmedPlaymaker 65:2872ca289b49 17 ~StartScreen();
AhmedPlaymaker 3:fbb1fa853f09 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 3:fbb1fa853f09 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 33:249cf423fb18 29 void screen_saver(N5110 &lcd, Gamepad &pad);
AhmedPlaymaker 3:fbb1fa853f09 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 3:fbb1fa853f09 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 49:441c32f6603e 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 3:fbb1fa853f09 48
AhmedPlaymaker 3:fbb1fa853f09 49 /** The First Menu Screen
AhmedPlaymaker 3:fbb1fa853f09 50 *
AhmedPlaymaker 3:fbb1fa853f09 51 * This function obtains the user input on how they want to progress.
AhmedPlaymaker 3:fbb1fa853f09 52 */
AhmedPlaymaker 49:441c32f6603e 53 void main_menu(N5110 &lcd, Gamepad &pad);
AhmedPlaymaker 30:461231877c89 54
AhmedPlaymaker 30:461231877c89 55 /** Displaying The First Menu Screen
AhmedPlaymaker 30:461231877c89 56 *
AhmedPlaymaker 30:461231877c89 57 * This function just displays Menu Screen 1 contents.
AhmedPlaymaker 30:461231877c89 58 */
AhmedPlaymaker 56:142e9fdb77a8 59 void ImplementMenu(N5110 &lcd, Gamepad &pad);
AhmedPlaymaker 34:89f53ffc81bb 60
AhmedPlaymaker 34:89f53ffc81bb 61 /** Implementing The First Menu Screen
AhmedPlaymaker 34:89f53ffc81bb 62 *
AhmedPlaymaker 34:89f53ffc81bb 63 * This function just implements the things decided in main menu.
AhmedPlaymaker 34:89f53ffc81bb 64 */
AhmedPlaymaker 56:142e9fdb77a8 65 void NextMenu(N5110 &lcd, Gamepad &pad);
AhmedPlaymaker 33:249cf423fb18 66
AhmedPlaymaker 4:1fe015b66bb8 67 /** The Second Menu Screen
AhmedPlaymaker 4:1fe015b66bb8 68 *
AhmedPlaymaker 4:1fe015b66bb8 69 * This function obtains the user input on the game type they would like to play.
AhmedPlaymaker 4:1fe015b66bb8 70 */
AhmedPlaymaker 49:441c32f6603e 71 void game_mode(N5110 &lcd, Gamepad &pad);
AhmedPlaymaker 4:1fe015b66bb8 72
AhmedPlaymaker 56:142e9fdb77a8 73 /** Displaying Mode Options
AhmedPlaymaker 42:973bb6036f81 74 *
AhmedPlaymaker 56:142e9fdb77a8 75 * This function displays game_mode contents.
AhmedPlaymaker 42:973bb6036f81 76 */
AhmedPlaymaker 56:142e9fdb77a8 77 void ModeOptions(N5110 &lcd);
AhmedPlaymaker 42:973bb6036f81 78
AhmedPlaymaker 56:142e9fdb77a8 79 /** Selecting the game mode
AhmedPlaymaker 34:89f53ffc81bb 80 *
AhmedPlaymaker 56:142e9fdb77a8 81 * value of g_mode is changed in this function that allows the choise beteen joystick/motion control..
AhmedPlaymaker 34:89f53ffc81bb 82 */
AhmedPlaymaker 56:142e9fdb77a8 83 void SelectMode(Gamepad &pad);
AhmedPlaymaker 34:89f53ffc81bb 84
AhmedPlaymaker 58:affb42c56cf8 85 /** Motion Control Instructions
AhmedPlaymaker 58:affb42c56cf8 86 *
AhmedPlaymaker 58:affb42c56cf8 87 * This promts the user to press A to centre position their angle if Motion Control is selected..
AhmedPlaymaker 58:affb42c56cf8 88 */
AhmedPlaymaker 58:affb42c56cf8 89 void motionControlInstructions(N5110 &lcd);
AhmedPlaymaker 58:affb42c56cf8 90
AhmedPlaymaker 4:1fe015b66bb8 91 /** The Third Menu Screen
AhmedPlaymaker 4:1fe015b66bb8 92 *
AhmedPlaymaker 4:1fe015b66bb8 93 * This function obtains the user input on the game speed that suits them.
AhmedPlaymaker 4:1fe015b66bb8 94 */
AhmedPlaymaker 49:441c32f6603e 95 void game_speed(N5110 &lcd, Gamepad &pad);
AhmedPlaymaker 33:249cf423fb18 96
AhmedPlaymaker 35:ce47cde57bd3 97 /** Implementing GS
AhmedPlaymaker 35:ce47cde57bd3 98 *
AhmedPlaymaker 35:ce47cde57bd3 99 * This function just decides what has to be done next.
AhmedPlaymaker 35:ce47cde57bd3 100 */
AhmedPlaymaker 58:affb42c56cf8 101 void selectSpeedPage(Gamepad &pad);
AhmedPlaymaker 35:ce47cde57bd3 102
AhmedPlaymaker 35:ce47cde57bd3 103 /** Displaying GAME speed Contents
AhmedPlaymaker 35:ce47cde57bd3 104 *
AhmedPlaymaker 35:ce47cde57bd3 105 * This function just displays game_speed contents.
AhmedPlaymaker 35:ce47cde57bd3 106 */
AhmedPlaymaker 58:affb42c56cf8 107 void showSpeedOptions(N5110 &lcd);
AhmedPlaymaker 35:ce47cde57bd3 108
AhmedPlaymaker 65:2872ca289b49 109 //SETTING THE GAME SPEED AND GAME MODE.
AhmedPlaymaker 65:2872ca289b49 110 int fps; // this sends over the game speed
AhmedPlaymaker 65:2872ca289b49 111 int g_mode; //this helps to select between joystick and motion control.
AhmedPlaymaker 65:2872ca289b49 112 int gameSpeedIndex;
AhmedPlaymaker 16:7b474f873683 113
AhmedPlaymaker 65:2872ca289b49 114 //MENU OPTIONS INDEX.
AhmedPlaymaker 30:461231877c89 115 int i;
AhmedPlaymaker 65:2872ca289b49 116
AhmedPlaymaker 65:2872ca289b49 117 //VARIABLE USED TO DECIDE WEATHER TO SHOW CREDITS.
AhmedPlaymaker 65:2872ca289b49 118 int showCredits;
AhmedPlaymaker 65:2872ca289b49 119
AhmedPlaymaker 65:2872ca289b49 120 //VARIABLE USED TO DECIDE THE WAIT TIME OF THE MENU PAGES.
AhmedPlaymaker 65:2872ca289b49 121 float controlSensitivity;
AhmedPlaymaker 65:2872ca289b49 122
AhmedPlaymaker 65:2872ca289b49 123 //VARIABLES TO TOGGLE BACK AND FORTH BETWEEN MENU OPTIONS.
AhmedPlaymaker 34:89f53ffc81bb 124 int back_pressed; //remembers if back is pressed.
AhmedPlaymaker 59:c65a2e933c47 125 int Start_Pressed; //remembers if start is pressed.
AhmedPlaymaker 33:249cf423fb18 126
AhmedPlaymaker 33:249cf423fb18 127 private:
AhmedPlaymaker 65:2872ca289b49 128
AhmedPlaymaker 65:2872ca289b49 129 //OBJECT DECLARATIONS
AhmedPlaymaker 33:249cf423fb18 130 Stats _stats;
AhmedPlaymaker 60:d3a9e0e4a0de 131 Settings _settings;
AhmedPlaymaker 60:d3a9e0e4a0de 132 Tutorial _tutorial;
AhmedPlaymaker 3:fbb1fa853f09 133
AhmedPlaymaker 3:fbb1fa853f09 134
AhmedPlaymaker 3:fbb1fa853f09 135
AhmedPlaymaker 3:fbb1fa853f09 136 };
AhmedPlaymaker 3:fbb1fa853f09 137 #endif