Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Pause/Pause.h@37:de1f584bce71, 2019-05-06 (annotated)
- Committer:
- JamesCummins
- Date:
- Mon May 06 21:44:49 2019 +0000
- Revision:
- 37:de1f584bce71
- Parent:
- 29:42651f87522b
- Child:
- 38:a85bc227b907
Documentation written out with the exception of example code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JamesCummins | 20:4a39a1a2be51 | 1 | #ifndef PAUSE_H |
JamesCummins | 20:4a39a1a2be51 | 2 | #define PAUSE_H |
JamesCummins | 20:4a39a1a2be51 | 3 | |
JamesCummins | 20:4a39a1a2be51 | 4 | #include "mbed.h" |
JamesCummins | 20:4a39a1a2be51 | 5 | #include "Gamepad.h" |
JamesCummins | 29:42651f87522b | 6 | #include "ClassicEngine.h" |
JamesCummins | 20:4a39a1a2be51 | 7 | #include "N5110.h" |
JamesCummins | 20:4a39a1a2be51 | 8 | |
JamesCummins | 37:de1f584bce71 | 9 | /** Enum for game mode*/ |
JamesCummins | 20:4a39a1a2be51 | 10 | enum Mode{ |
JamesCummins | 37:de1f584bce71 | 11 | CLASSIC_MODE, |
JamesCummins | 21:9d1447765ee1 | 12 | BRICKBREAKER_MODE |
JamesCummins | 20:4a39a1a2be51 | 13 | }; |
JamesCummins | 37:de1f584bce71 | 14 | |
JamesCummins | 37:de1f584bce71 | 15 | /** Enum for Pause Options*/ |
JamesCummins | 20:4a39a1a2be51 | 16 | enum PauseOption{ |
JamesCummins | 20:4a39a1a2be51 | 17 | RESUME, |
JamesCummins | 20:4a39a1a2be51 | 18 | RESTART, |
JamesCummins | 20:4a39a1a2be51 | 19 | QUIT, |
JamesCummins | 20:4a39a1a2be51 | 20 | HELP |
JamesCummins | 20:4a39a1a2be51 | 21 | }; |
JamesCummins | 20:4a39a1a2be51 | 22 | |
JamesCummins | 37:de1f584bce71 | 23 | /**Pause selection struct*/ |
JamesCummins | 20:4a39a1a2be51 | 24 | struct PauseSelection{ |
JamesCummins | 37:de1f584bce71 | 25 | int output; /**<Integer output for line to print arrows*/ |
JamesCummins | 37:de1f584bce71 | 26 | PauseOption next_state[3]; /**<Array of enums for possible next option*/ |
JamesCummins | 20:4a39a1a2be51 | 27 | }; |
JamesCummins | 20:4a39a1a2be51 | 28 | |
JamesCummins | 20:4a39a1a2be51 | 29 | class Pause { |
JamesCummins | 20:4a39a1a2be51 | 30 | |
JamesCummins | 20:4a39a1a2be51 | 31 | public: |
JamesCummins | 37:de1f584bce71 | 32 | /** |
JamesCummins | 37:de1f584bce71 | 33 | * @brief Create a Pause object |
JamesCummins | 37:de1f584bce71 | 34 | */ |
JamesCummins | 22:4e305ff8a050 | 35 | Pause(); |
JamesCummins | 37:de1f584bce71 | 36 | /** |
JamesCummins | 37:de1f584bce71 | 37 | * @brief Delete Pause object to free memory |
JamesCummins | 37:de1f584bce71 | 38 | */ |
JamesCummins | 22:4e305ff8a050 | 39 | ~Pause(); |
JamesCummins | 37:de1f584bce71 | 40 | /** |
JamesCummins | 37:de1f584bce71 | 41 | * @brief Initialise the pause menu with the first menu option highlighted |
JamesCummins | 37:de1f584bce71 | 42 | */ |
JamesCummins | 22:4e305ff8a050 | 43 | void init(); |
JamesCummins | 37:de1f584bce71 | 44 | /** |
JamesCummins | 37:de1f584bce71 | 45 | * @brief Read the user input and update the displayed menu until an option is selected |
JamesCummins | 37:de1f584bce71 | 46 | * @param gamepad - Gamepad object to sense user interaction |
JamesCummins | 37:de1f584bce71 | 47 | * @param lcd - N5110 object to render menu on LCD screen |
JamesCummins | 37:de1f584bce71 | 48 | * @param fps - integer value of frames per second game is ran at |
JamesCummins | 37:de1f584bce71 | 49 | * @returns an Enum of the pause option selected by user (RESUME, RESTART, QUIT or HELP) |
JamesCummins | 37:de1f584bce71 | 50 | */ |
JamesCummins | 29:42651f87522b | 51 | PauseOption pause_menu(Gamepad &gamepad, N5110 &lcd, int fps); |
JamesCummins | 37:de1f584bce71 | 52 | /** |
JamesCummins | 37:de1f584bce71 | 53 | * @brief Jump to a specified frame in the game based on user's menu choice |
JamesCummins | 37:de1f584bce71 | 54 | * @param choice - option selected in the Pause menu |
JamesCummins | 37:de1f584bce71 | 55 | * @param gamepad - Gamepad object to check for button press |
JamesCummins | 37:de1f584bce71 | 56 | * @param lcd - N5110 object to interact with LCD screen |
JamesCummins | 37:de1f584bce71 | 57 | * @param frame - integer of current no. of frames iterated through in gameplay |
JamesCummins | 37:de1f584bce71 | 58 | * @param fps - integer of gameplay's frames per second |
JamesCummins | 37:de1f584bce71 | 59 | * @returns i - integer of frame to jump to |
JamesCummins | 37:de1f584bce71 | 60 | */ |
JamesCummins | 29:42651f87522b | 61 | int brickbreaker_action(PauseOption choice, Gamepad &gamepad, N5110 &lcd, int frame, int fps); |
JamesCummins | 37:de1f584bce71 | 62 | /** |
JamesCummins | 37:de1f584bce71 | 63 | * @brief Display the help menu for classic game mode |
JamesCummins | 37:de1f584bce71 | 64 | * @param gamepad - Gamepad object to check for button press |
JamesCummins | 37:de1f584bce71 | 65 | * @param lcd - N5110 object to render help menu on LCD |
JamesCummins | 37:de1f584bce71 | 66 | */ |
JamesCummins | 29:42651f87522b | 67 | void classic_help(Gamepad &gamepad, N5110 &lcd); |
JamesCummins | 37:de1f584bce71 | 68 | /** |
JamesCummins | 37:de1f584bce71 | 69 | * @brief Display the help menu for brickbreaker game mode |
JamesCummins | 37:de1f584bce71 | 70 | * @param gamepad - Gamepad object to check for button press |
JamesCummins | 37:de1f584bce71 | 71 | * @param lcd - N5110 object to render help menu on LCD |
JamesCummins | 37:de1f584bce71 | 72 | */ |
JamesCummins | 29:42651f87522b | 73 | void brickbreaker_help(Gamepad &gamepad, N5110 &lcd); |
JamesCummins | 20:4a39a1a2be51 | 74 | |
JamesCummins | 20:4a39a1a2be51 | 75 | private: |
JamesCummins | 20:4a39a1a2be51 | 76 | |
JamesCummins | 22:4e305ff8a050 | 77 | void display_pause_options(N5110 &lcd); |
JamesCummins | 22:4e305ff8a050 | 78 | PauseOption pause_selection(Gamepad &gamepad, N5110 &lcd); |
JamesCummins | 22:4e305ff8a050 | 79 | PauseOption _state; |
JamesCummins | 22:4e305ff8a050 | 80 | int _next_state; |
JamesCummins | 20:4a39a1a2be51 | 81 | }; |
JamesCummins | 20:4a39a1a2be51 | 82 | #endif |