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 Class Reference
#include <Pause.h>
Public Member Functions | |
| Pause () | |
| Create a Pause object. | |
| ~Pause () | |
| Delete Pause object to free memory. | |
| void | init () |
| Initialise the pause menu with the first menu option highlighted. | |
| PauseOption | pause_menu (Gamepad &gamepad, N5110 &lcd, int fps) |
| Read the user input and update the displayed menu until an option is selected. | |
| int | brickbreaker_action (PauseOption choice, Gamepad &gamepad, N5110 &lcd, int frame, int fps) |
| Jump to a specified frame in the game based on user's menu choice. | |
| void | classic_help (Gamepad &gamepad, N5110 &lcd) |
| Display the help menu for classic game mode. | |
| void | brickbreaker_help (Gamepad &gamepad, N5110 &lcd) |
| Display the help menu for brickbreaker game mode. | |
Detailed Description
Pause Class.
Library to power the pause menu Can pass frame values to control the flow of the game modes they're utilised in, enabling features like restarting and quitting
#include "mbed.h" #include "Pause.h" Pause pause; //create a pause object for the pause menu Gamepad gamepad; N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); int main(){ //first initialise the pause menu so it points to top item first pause.init(); int game_length = 90; //desired game mode length in seconds int fps = 30; //frames per sec of the game mode //use either one or the other of these (for the correct game mode) //to display instructions before the game commences pause.brickbreaker_help(gamepad, lcd); pause.classic_help(gamepad, lcd); for(int i = 0; i < game_length*fps; i++){ // // //code to operate a time based game mode // // if(gamepad.check_event(gamepad.BACK_PRESSED)){ //retrieve the user's choice from the pause menu PauseOption choice = pause.pause_menu(gamepad, lcd, fps); //jump to the appropriate point in the game mode i = pause.brickbreaker_action(choice, gamepad, lcd, i, fps); } } }
Definition at line 75 of file Pause.h.
Constructor & Destructor Documentation
Member Function Documentation
Jump to a specified frame in the game based on user's menu choice.
- Parameters:
-
choice - option selected in the Pause menu gamepad - Gamepad object to check for button press lcd - N5110 object to interact with LCD screen frame - integer of current no. of frames iterated through in gameplay fps - integer of gameplay's frames per second
- Returns:
- i - integer of frame to jump to
| void init | ( | ) |
Read the user input and update the displayed menu until an option is selected.
- Parameters:
-
gamepad - Gamepad object to sense user interaction lcd - N5110 object to render menu on LCD screen fps - integer value of frames per second game is ran at
- Returns:
- an Enum of the pause option selected by user (RESUME, RESTART, QUIT or HELP)
Generated on Thu Jul 14 2022 00:39:27 by
1.7.2