Menu class used as basis for program; running the game and allowing the user to change the style and difficulty of the game via an interface.

Committer:
el15mh
Date:
Thu May 04 14:01:32 2017 +0000
Revision:
6:2a05dd8b9750
Parent:
5:56f13954666e
Doxygen commenting added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el15mh 6:2a05dd8b9750 1 /** Menu Class
el15mh 6:2a05dd8b9750 2 @brief Class runs the menu which the program uses as a basis.
el15mh 6:2a05dd8b9750 3 @author Max Houghton
el15mh 6:2a05dd8b9750 4 @date April 4 2017
el15mh 1:21b7a5edb9c2 5 */
el15mh 0:b32f6570a26d 6
el15mh 0:b32f6570a26d 7 #ifndef MENU_H
el15mh 0:b32f6570a26d 8 #define MENU_H
el15mh 0:b32f6570a26d 9
el15mh 4:4f20bcef2c0c 10 #include <stdlib.h> // used to generate random number values
el15mh 4:4f20bcef2c0c 11
el15mh 0:b32f6570a26d 12 #include "mbed.h"
el15mh 0:b32f6570a26d 13 #include "N5110.h"
el15mh 0:b32f6570a26d 14 #include "Gamepad.h"
el15mh 2:917211a4551b 15 #include "MazeEngine.h"
el15mh 3:a79daa7c2b55 16 #include "Animations.h"
el15mh 2:917211a4551b 17 #include "Maze.h"
el15mh 2:917211a4551b 18 #include "Ball.h"
el15mh 0:b32f6570a26d 19
el15mh 0:b32f6570a26d 20 class Menu
el15mh 0:b32f6570a26d 21 {
el15mh 2:917211a4551b 22
el15mh 0:b32f6570a26d 23 public:
el15mh 0:b32f6570a26d 24
el15mh 6:2a05dd8b9750 25 /**
el15mh 6:2a05dd8b9750 26 * @details - constructor
el15mh 6:2a05dd8b9750 27 */
el15mh 0:b32f6570a26d 28 Menu();
el15mh 6:2a05dd8b9750 29
el15mh 6:2a05dd8b9750 30 /**
el15mh 6:2a05dd8b9750 31 * @details - destructor
el15mh 6:2a05dd8b9750 32 */
el15mh 0:b32f6570a26d 33 ~Menu();
el15mh 0:b32f6570a26d 34
el15mh 6:2a05dd8b9750 35 /** Initialise Menu
el15mh 6:2a05dd8b9750 36 *
el15mh 6:2a05dd8b9750 37 * @details - Creates objects and default parameters for the game
el15mh 6:2a05dd8b9750 38 *
el15mh 6:2a05dd8b9750 39 */
el15mh 3:a79daa7c2b55 40 void init();
el15mh 6:2a05dd8b9750 41
el15mh 6:2a05dd8b9750 42 /** Main Menu Function
el15mh 6:2a05dd8b9750 43 *
el15mh 6:2a05dd8b9750 44 * @details - The main function which runs the game and allows player to select all different game parameters.
el15mh 6:2a05dd8b9750 45 * @param - lcd - N5110 Library, used for drawing strings and printing bitmaps
el15mh 6:2a05dd8b9750 46 * @param - pad - Gamepad Library, used to read inputs from peripheral devides on the handheld gamepad device.
el15mh 6:2a05dd8b9750 47 * @param - device - FXOS8700CQ Libary, used to read data from accelerometer
el15mh 6:2a05dd8b9750 48 * @param - animate - Animations Library to provide short animations.
el15mh 6:2a05dd8b9750 49 *
el15mh 6:2a05dd8b9750 50 */
el15mh 4:4f20bcef2c0c 51 void main(N5110 &lcd,
el15mh 4:4f20bcef2c0c 52 Gamepad &pad,
el15mh 4:4f20bcef2c0c 53 FXOS8700CQ &device,
el15mh 4:4f20bcef2c0c 54 Animations &animate);
el15mh 4:4f20bcef2c0c 55
el15mh 6:2a05dd8b9750 56 /** Intro Function
el15mh 6:2a05dd8b9750 57 *
el15mh 6:2a05dd8b9750 58 * @details - The main function which runs the game and allows player to select all different game parameters.
el15mh 6:2a05dd8b9750 59 * @details - Called from main file when the game is loading.
el15mh 6:2a05dd8b9750 60 * @param - lcd - N5110 Library, used for drawing strings and printing bitmaps
el15mh 6:2a05dd8b9750 61 * @param - pad - Gamepad Library, used to read inputs from peripheral devides on the handheld gamepad device.
el15mh 6:2a05dd8b9750 62 * @param - animate - Animations Library to provide short animations.
el15mh 6:2a05dd8b9750 63 *
el15mh 6:2a05dd8b9750 64 */
el15mh 4:4f20bcef2c0c 65 void intro(N5110 &lcd, Gamepad &pad, Animations &animate);
el15mh 0:b32f6570a26d 66
el15mh 0:b32f6570a26d 67 private:
el15mh 2:917211a4551b 68
el15mh 6:2a05dd8b9750 69 /**
el15mh 6:2a05dd8b9750 70 *
el15mh 6:2a05dd8b9750 71 * @details - Game Loop function.
el15mh 6:2a05dd8b9750 72 * @param - lcd - N5110 Library, used for drawing strings and printing bitmaps
el15mh 6:2a05dd8b9750 73 * @param - pad - Gamepad Library, used to read inputs from peripheral devides on the handheld gamepad device.
el15mh 6:2a05dd8b9750 74 * @param - device - FXOS8700CQ Libary, used to read data from accelerometer
el15mh 6:2a05dd8b9750 75 * @param - animate - Animations Library to provide short animations.
el15mh 6:2a05dd8b9750 76 * @param - difficulty - Integer value to specificy desired difficulty; maze Index is randomly chosen according to difficulty value.
el15mh 6:2a05dd8b9750 77 * @param - tone - Boolean value to select whether sound is used or not.
el15mh 6:2a05dd8b9750 78 * @param - FPS - Specifies the frame rate at which the game is to be played at.
el15mh 6:2a05dd8b9750 79 *
el15mh 6:2a05dd8b9750 80 */
el15mh 6:2a05dd8b9750 81 void playGame(N5110 &lcd,
el15mh 6:2a05dd8b9750 82 Gamepad &pad,
el15mh 6:2a05dd8b9750 83 FXOS8700CQ &device,
el15mh 6:2a05dd8b9750 84 Animations &animate,
el15mh 6:2a05dd8b9750 85 int mazeIndex,
el15mh 6:2a05dd8b9750 86 bool tone,
el15mh 6:2a05dd8b9750 87 float FPS);
el15mh 6:2a05dd8b9750 88
el15mh 6:2a05dd8b9750 89 /**
el15mh 6:2a05dd8b9750 90 *
el15mh 6:2a05dd8b9750 91 * @details - Prints all chosen game parameters to serial port - used mostly for debugging.
el15mh 6:2a05dd8b9750 92 * @param - mazeIndex - specifies which of the 10 mazes is to be drawn.
el15mh 6:2a05dd8b9750 93 * @param - x - x coordiante for centre of ball when drawn initially.
el15mh 6:2a05dd8b9750 94 * @param - y - y coordiante for centre of ball when drawn initially.
el15mh 6:2a05dd8b9750 95 * @param - control - Boolean value to specify desired control method.
el15mh 6:2a05dd8b9750 96 * @param - colour - Boolean value to select type of ball; filled or transparent.
el15mh 6:2a05dd8b9750 97 * @param - FPS - Specifies the frame rate at which the game is to be played at.
el15mh 6:2a05dd8b9750 98 *
el15mh 6:2a05dd8b9750 99 */
el15mh 4:4f20bcef2c0c 100 void printGameParameters(int mazeIndex,
el15mh 4:4f20bcef2c0c 101 int x,
el15mh 4:4f20bcef2c0c 102 int y,
el15mh 4:4f20bcef2c0c 103 int radius,
el15mh 4:4f20bcef2c0c 104 bool control,
el15mh 4:4f20bcef2c0c 105 bool colour,
el15mh 4:4f20bcef2c0c 106 float FPS);
el15mh 4:4f20bcef2c0c 107
el15mh 6:2a05dd8b9750 108
el15mh 6:2a05dd8b9750 109 /**
el15mh 6:2a05dd8b9750 110 *
el15mh 6:2a05dd8b9750 111 * @details - Game Options Function to allow user to choose game style.
el15mh 6:2a05dd8b9750 112 * @param - lcd - N5110 Library, used for drawing strings and printing bitmaps
el15mh 6:2a05dd8b9750 113 * @param - pad - Gamepad Library, used to read inputs from peripheral devides on the handheld gamepad device.
el15mh 6:2a05dd8b9750 114 * @param - animate - Animations Library to provide short animations.
el15mh 6:2a05dd8b9750 115 * @param - tone - Boolean value to select whether sound is used or not.
el15mh 6:2a05dd8b9750 116 */
el15mh 6:2a05dd8b9750 117 void options(N5110 &lcd, Gamepad &pad, Animations &animate, bool tone);
el15mh 6:2a05dd8b9750 118
el15mh 6:2a05dd8b9750 119
el15mh 6:2a05dd8b9750 120 /**
el15mh 6:2a05dd8b9750 121 *
el15mh 6:2a05dd8b9750 122 * @details - LCD Settings Function to allow user to alter appearance of game on LCD.
el15mh 6:2a05dd8b9750 123 * @param - lcd - N5110 Library, used for drawing strings and printing bitmaps
el15mh 6:2a05dd8b9750 124 * @param - pad - Gamepad Library, used to read inputs from peripheral devides on the handheld gamepad device.
el15mh 6:2a05dd8b9750 125 * @param - animate - Animations Library to provide short animations.
el15mh 6:2a05dd8b9750 126 *
el15mh 6:2a05dd8b9750 127 */
el15mh 6:2a05dd8b9750 128 void lcdSettings(N5110 &lcd, Gamepad &pad, Animations &animate);
el15mh 6:2a05dd8b9750 129
el15mh 6:2a05dd8b9750 130 /**
el15mh 6:2a05dd8b9750 131 *
el15mh 6:2a05dd8b9750 132 * @details - Sound Settings to allow user to turn sound on or off. This changes the boolean value of the '_tone' variable.
el15mh 6:2a05dd8b9750 133 * @param - lcd - N5110 Library, used for drawing strings and printing bitmaps
el15mh 6:2a05dd8b9750 134 * @param - pad - Gamepad Library, used to read inputs from peripheral devides on the handheld gamepad device.
el15mh 6:2a05dd8b9750 135 * @param - animate - Animations Library to animate slide bar to display brightness level settings.
el15mh 6:2a05dd8b9750 136 *
el15mh 6:2a05dd8b9750 137 */
el15mh 6:2a05dd8b9750 138 void soundSettings(N5110 &lcd, Gamepad &pad, Animations &animate);
el15mh 4:4f20bcef2c0c 139
el15mh 6:2a05dd8b9750 140 /**
el15mh 6:2a05dd8b9750 141 *
el15mh 6:2a05dd8b9750 142 * @details - Control Options Function which allows user select control technique. This chanes the boolean value of the '_control' variable.
el15mh 6:2a05dd8b9750 143 * @param - lcd - N5110 Library, used for drawing strings and printing bitmaps
el15mh 6:2a05dd8b9750 144 * @param - pad - Gamepad Library, used to read inputs from peripheral devides on the handheld gamepad device.
el15mh 6:2a05dd8b9750 145 * @param - animate -Animations Library to provide animations for either joystick or gamepad tilt selection.
el15mh 6:2a05dd8b9750 146 *
el15mh 6:2a05dd8b9750 147 */
el15mh 4:4f20bcef2c0c 148 void controlOptions(N5110 &lcd, Gamepad &pad, Animations &animate);
el15mh 6:2a05dd8b9750 149
el15mh 6:2a05dd8b9750 150 /**
el15mh 6:2a05dd8b9750 151 *
el15mh 6:2a05dd8b9750 152 * @details - Difficulty Options Function to allow player to select difficulty level. This changes the value of integer variable '_difficulty' to 1, 2, 3 or 4. The maze index for the maze is then selected randomly according to this difficulty value.
el15mh 6:2a05dd8b9750 153 * @param - lcd - N5110 Library, used for drawing strings and printing bitmaps
el15mh 6:2a05dd8b9750 154 * @param - pad - Gamepad Library, used to read inputs from peripheral devides on the handheld gamepad device.
el15mh 6:2a05dd8b9750 155 *
el15mh 6:2a05dd8b9750 156 */
el15mh 4:4f20bcef2c0c 157 void difficultyOptions(N5110 &lcd, Gamepad &pad);
el15mh 6:2a05dd8b9750 158
el15mh 6:2a05dd8b9750 159 /**
el15mh 6:2a05dd8b9750 160 *
el15mh 6:2a05dd8b9750 161 * @details - Ball colour function to select the style of ball used in the game. This function changes the value of boolean variable '_colour'; true corresponds to a transparent fill and false to solid fill.
el15mh 6:2a05dd8b9750 162 * @param - lcd - N5110 Library, used for drawing strings and printing bitmaps
el15mh 6:2a05dd8b9750 163 * @param - pad - Gamepad Library, used to read inputs from peripheral devides on the handheld gamepad device.
el15mh 6:2a05dd8b9750 164 * @param - animate - Animations Library to provide animations for either solid or transparent fill selection.
el15mh 6:2a05dd8b9750 165 *
el15mh 6:2a05dd8b9750 166 */
el15mh 4:4f20bcef2c0c 167 void ballColourOptions(N5110 &lcd, Gamepad &pad, Animations &animate);
el15mh 6:2a05dd8b9750 168
el15mh 6:2a05dd8b9750 169 /**
el15mh 6:2a05dd8b9750 170 *s
el15mh 6:2a05dd8b9750 171 * @details - LCD Inverse Colour function which allows user to switch colours on the LCD.
el15mh 6:2a05dd8b9750 172 * @param - lcd - N5110 Library, used for drawing strings and printing bitmaps
el15mh 6:2a05dd8b9750 173 * @param - pad - Gamepad Library, used to read inputs from peripheral devides on the handheld gamepad device.
el15mh 6:2a05dd8b9750 174 *
el15mh 6:2a05dd8b9750 175 */
el15mh 4:4f20bcef2c0c 176 void lcdInverseColour(N5110 &lcd, Gamepad &pad);
el15mh 6:2a05dd8b9750 177
el15mh 6:2a05dd8b9750 178 /**
el15mh 6:2a05dd8b9750 179 * @details - LCD Background Colour function which changes the PWM value of the LCD backlight LED.
el15mh 6:2a05dd8b9750 180 * @param - lcd - N5110 Library, used for drawing strings and printing bitmaps
el15mh 6:2a05dd8b9750 181 * @param - pad - Gamepad Library, used to read inputs from peripheral devides on the handheld gamepad device.
el15mh 6:2a05dd8b9750 182 * @param - animate - Animations Library to provide animation for switch.
el15mh 6:2a05dd8b9750 183 */
el15mh 4:4f20bcef2c0c 184 void lcdBackgroundColour(N5110 &lcd, Gamepad &pad, Animations &animate);
el15mh 4:4f20bcef2c0c 185
el15mh 6:2a05dd8b9750 186 /**
el15mh 6:2a05dd8b9750 187 * @details - Animate Joystick function creats a short animation of moving joystick.
el15mh 6:2a05dd8b9750 188 * @param - lcd - N5110 Library, used for drawing strings and printing bitmaps
el15mh 6:2a05dd8b9750 189 * @param - animate - Animations Library to provide animation for moving joystick bitmaps.
el15mh 6:2a05dd8b9750 190 */
el15mh 4:4f20bcef2c0c 191 void animateJoystick(N5110 &lcd, Animations &animate);
el15mh 6:2a05dd8b9750 192
el15mh 6:2a05dd8b9750 193 /**
el15mh 6:2a05dd8b9750 194 * @details - Animate Gamepad function creats a short animation of moving gamepad.
el15mh 6:2a05dd8b9750 195 * @param - lcd - N5110 Library, used for drawing strings and printing bitmaps
el15mh 6:2a05dd8b9750 196 * @param - animate - Animations Library to provide animation for moving gamepad bitmaps.
el15mh 6:2a05dd8b9750 197 */
el15mh 4:4f20bcef2c0c 198 void animateGamepad(N5110 &lcd, Animations &animate);
el15mh 6:2a05dd8b9750 199
el15mh 6:2a05dd8b9750 200 /**
el15mh 6:2a05dd8b9750 201 * @details - Animate Stickman function creates a short animation of jumping man to signify goal reached.
el15mh 6:2a05dd8b9750 202 * @param - lcd - N5110 Library, used for drawing strings and printing bitmaps
el15mh 6:2a05dd8b9750 203 * @param - pad - Gamepad Library, used to flash LEDS on and off.
el15mh 6:2a05dd8b9750 204 * @param - animate - Animations Library to provide animation for moving stickman bitmap.
el15mh 6:2a05dd8b9750 205 */
el15mh 4:4f20bcef2c0c 206 void animateStickman(N5110 &lcd, Gamepad &pad, Animations &animate);
el15mh 4:4f20bcef2c0c 207
el15mh 6:2a05dd8b9750 208 /**
el15mh 6:2a05dd8b9750 209 * @details - Game Speed function which changes the FPS used in the game loop.
el15mh 6:2a05dd8b9750 210 * @param - lcd - N5110 Library, used for drawing strings and printing bitmaps
el15mh 6:2a05dd8b9750 211 * @param - pad - Gamepad Library, used to read inputs from peripheral devides on the handheld gamepad device.
el15mh 6:2a05dd8b9750 212 */
el15mh 4:4f20bcef2c0c 213 void speedSettings(N5110 &lcd, Gamepad &pad);
el15mh 4:4f20bcef2c0c 214
el15mh 6:2a05dd8b9750 215 /**
el15mh 6:2a05dd8b9750 216 * @details - Returns a random number between two set values
el15mh 6:2a05dd8b9750 217 * @param - difficulty - Specified value dictating the level of maze to be played
el15mh 6:2a05dd8b9750 218 */
el15mh 5:56f13954666e 219 int randomMazeIndexGenerator(int difficulty);
el15mh 5:56f13954666e 220
el15mh 6:2a05dd8b9750 221 /**
el15mh 6:2a05dd8b9750 222 * @details - Creates _engine object to be used when running the game loop.
el15mh 6:2a05dd8b9750 223 * @param - _engine - instance of MazeEngine class.
el15mh 6:2a05dd8b9750 224 */
el15mh 2:917211a4551b 225 MazeEngine _engine;
el15mh 2:917211a4551b 226
el15mh 6:2a05dd8b9750 227 /**
el15mh 6:2a05dd8b9750 228 * @details - Integer to select the specific maze to be drawn by engine.
el15mh 6:2a05dd8b9750 229 * @param - _mazeIndex - variable to be passed down to engine.
el15mh 6:2a05dd8b9750 230 */
el15mh 2:917211a4551b 231 int _mazeIndex;
el15mh 6:2a05dd8b9750 232
el15mh 6:2a05dd8b9750 233 /**
el15mh 6:2a05dd8b9750 234 * @details - Integer to select the desired difficulty by user.
el15mh 6:2a05dd8b9750 235 * @param - _difficulty - variable to be passed down to engine. Value used in randomMazeIndexGenerator() function
el15mh 6:2a05dd8b9750 236 */
el15mh 5:56f13954666e 237 int _difficulty;
el15mh 4:4f20bcef2c0c 238
el15mh 6:2a05dd8b9750 239 /**
el15mh 6:2a05dd8b9750 240 * @details - Integer to select the frame rate at which the game is updated at.
el15mh 6:2a05dd8b9750 241 * @param - _FPS - value is used as delay between updates when running game loop
el15mh 6:2a05dd8b9750 242 */
el15mh 4:4f20bcef2c0c 243 float _FPS;
el15mh 4:4f20bcef2c0c 244
el15mh 6:2a05dd8b9750 245 /**
el15mh 6:2a05dd8b9750 246 * @details - Boolean value to select the desired control method by user.
el15mh 6:2a05dd8b9750 247 * @param - _control - value of true corresponds to joystick input, false corresponds to accelerometer values used as input.
el15mh 6:2a05dd8b9750 248 */
el15mh 3:a79daa7c2b55 249 bool _control;
el15mh 6:2a05dd8b9750 250
el15mh 6:2a05dd8b9750 251 /**
el15mh 6:2a05dd8b9750 252 * @details - Boolean value to select the desired ball fill type.
el15mh 6:2a05dd8b9750 253 * @param - _control - value of true corresponds to transparent fill, false corresponds to solid fill of ball when playing the game.
el15mh 6:2a05dd8b9750 254 */
el15mh 3:a79daa7c2b55 255 bool _colour;
el15mh 6:2a05dd8b9750 256
el15mh 6:2a05dd8b9750 257 /**
el15mh 6:2a05dd8b9750 258 * @details - Boolean value to signify when the goal has been reached.
el15mh 6:2a05dd8b9750 259 * @param - _goal - when this variable becomes true, the particular maze has been completed.
el15mh 6:2a05dd8b9750 260 */
el15mh 4:4f20bcef2c0c 261 bool _goal;
el15mh 6:2a05dd8b9750 262
el15mh 6:2a05dd8b9750 263 /**
el15mh 6:2a05dd8b9750 264 * @details - Boolean value to dictate if the buzzer on the gamepad is to be used in the menu when moving between options or selecting desired parameters.
el15mh 6:2a05dd8b9750 265 * @param - _tone - A true value allows for sound to be used in the menu.
el15mh 6:2a05dd8b9750 266 */
el15mh 4:4f20bcef2c0c 267 bool _tone;
el15mh 2:917211a4551b 268
el15mh 0:b32f6570a26d 269 };
el15mh 0:b32f6570a26d 270
el15mh 2:917211a4551b 271 #endif /* MENU_H */