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.
Diff: Menu.cpp
- Revision:
- 6:2a05dd8b9750
- Parent:
- 5:56f13954666e
diff -r 56f13954666e -r 2a05dd8b9750 Menu.cpp --- a/Menu.cpp Wed May 03 21:13:31 2017 +0000 +++ b/Menu.cpp Thu May 04 14:01:32 2017 +0000 @@ -1,12 +1,3 @@ -/* - - @file Menu.cpp - - (c) Max Houghton 02.04.17 - Roller Maze Project, ELEC2645, Univeristy of Leeds - - */ - #include "Menu.h" // constructor function used when object is initialised @@ -21,10 +12,13 @@ } +/** + * @details - Initiases the game with default parameters before value specification +*/ void Menu::init() { // set all default game parameters - _difficulty = 4; + _difficulty = 1; _FPS = 50; _control = true; @@ -32,7 +26,10 @@ _tone = true; } -/// MAIN MENU METHOD /// +/** + * @details - Main menu function. + + */ void Menu::main(N5110 &lcd, Gamepad &pad, FXOS8700CQ &device, Animations &animate) { int selected = 0; @@ -178,7 +175,9 @@ } } -/// INTRO LOOP /// +/** + * @details - Game introduction function. + */ void Menu::intro(N5110 &lcd, Gamepad &pad, Animations &animate) { // printf("intro started \n"); @@ -188,7 +187,9 @@ } } -/// GAME LOOP /// +/** + * @details - Game Loop function. + */ void Menu::playGame(N5110 &lcd, Gamepad &pad, FXOS8700CQ &device, @@ -206,7 +207,7 @@ // pairs of values with corresponding difficulties _FPS = 100 - FPS; - // from function, low FPS value corresponds to fast gameplay + // from game speed fuction (line , low FPS value corresponds to fast gameplay // so perform basic inversion (works when value is between 25 - 75) if (difficulty == 1) { @@ -284,6 +285,9 @@ } } +/** + * @details - Returns a random number between two set values + */ int Menu::randomMazeIndexGenerator(int difficulty) { // generates a random number between a pair of values @@ -314,6 +318,9 @@ return _mazeIndex; } +/** + * @details - Prints all chosen game parameters to serial port - used mostly for debugging. + */ void Menu::printGameParameters(int mazeIndex, int x, int y, @@ -353,7 +360,9 @@ } -/// MENU FUNCTIONS /// +/** + * @details - Game Options Function to allow user to choose game style. + */ void Menu::options(N5110 &lcd, Gamepad &pad, Animations &animate, bool tone) { int exit = 0; @@ -511,6 +520,9 @@ } } +/** + * @details - LCD Settings Function to allow user to alter appearance of game on LCD. + */ void Menu::lcdSettings(N5110 &lcd, Gamepad &pad, Animations &animate) { int exit = 0; @@ -610,6 +622,9 @@ } +/** + * @details - Sound Settings to allow user to turn sound on or off + */ void Menu::soundSettings(N5110 &lcd, Gamepad &pad, Animations &animate) { int exit = 0; @@ -665,6 +680,9 @@ } +/** + * @details - Control Options Function which allows user select control technique. + */ void Menu::controlOptions(N5110 &lcd, Gamepad &pad, Animations &animate) { int selected = 0; @@ -763,7 +781,9 @@ } } - +/** + * @details - Difficulty Options Function to allow player to select difficulty level. + */ void Menu::difficultyOptions(N5110 &lcd, Gamepad &pad) { int selected = 0; @@ -944,6 +964,9 @@ } } +/** + * @details - Ball colour function to select the style of ball used in the game. + */ void Menu::ballColourOptions(N5110 &lcd, Gamepad &pad, Animations &animate) { int selected = 0; @@ -1048,6 +1071,9 @@ } +/** + * @details - LCD Inverse Colour function which allows user to switch colours on the LCD. + */ void Menu::lcdInverseColour(N5110 &lcd, Gamepad &pad) { int exit = 0; @@ -1093,6 +1119,9 @@ } +/** + * @details - LCD Inverse Colour function which changes the PWM value of the LCD backlight LED. + */ void Menu::lcdBackgroundColour(N5110 &lcd, Gamepad &pad, Animations &animate) { // method to change the brightness of the LED backlight @@ -1131,6 +1160,9 @@ } } +/** + * @details - Game Speed function which changes the FPS used in the game loop. + */ void Menu::speedSettings(N5110 &lcd, Gamepad &pad) { int exit = 0; @@ -1181,6 +1213,9 @@ } } +/** + * @details - Animate Joystick function creats a short animation of moving joystick. + */ void Menu::animateJoystick(N5110 &lcd, Animations &animate) { int timer = 0; @@ -1220,7 +1255,9 @@ } } - +/** + * @details - Animate Gamepad function creats a short animation of moving gamepad. + */ void Menu::animateGamepad(N5110 &lcd, Animations &animate) { int timer = 0; @@ -1261,6 +1298,9 @@ } } +/** + * @details - Animate Stickman function creates a short animation of jumping man to signify goal reached. + */ void Menu::animateStickman(N5110 &lcd, Gamepad &pad, Animations &animate) { int timer = 0;