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.
Dependencies: mbed
Diff: Game/Game.h
- Revision:
- 39:41dcf1604fdf
- Parent:
- 38:cc5461dd0369
- Child:
- 40:065f0e4d6652
--- a/Game/Game.h Mon Apr 29 15:23:07 2019 +0000
+++ b/Game/Game.h Tue May 07 16:57:26 2019 +0000
@@ -12,24 +12,47 @@
#include "SDFileSystem.h"
/** Input struct
-Stores current details of required inputs, this being the joystick x axis, the a, b and y buttons. It also stores whether the button press can be registered yet to remove the switch bouncing issue.
+*Stores current details of required inputs, this being the joystick x axis, the a, b and y buttons. It also stores whether the button press can be registered yet to remove the switch bouncing issue.
+*@code
+*void Game::processInput(){ //Obtain user inputs and store in input struct
+* input.x = gamepad.get_coord().x; //Get value of joystick x axis
+* bool y = gamepad.check_event(Gamepad::Y_PRESSED);
+* bool a = gamepad.check_event(Gamepad::A_PRESSED);
+* bool b = gamepad.check_event(Gamepad::B_PRESSED);
+*
+* disableYButton(y);
+* disableAButton(a);
+* disableBButton(b);
+*}
+*
+*void Game::disableYButton(bool y){ //Set y button to disabled, call function to reenable in 0.2 seconds
+* if(!input.yCooldown && y){
+* input.yCooldown = true;
+* disableY.attach(callback(this, &Game::enableY), 0.2); //attach function to ticker to renable y button
+* input.yButton = true;
+* }
+* else{
+* input.yButton = false;
+* }
+*}
*/
struct Input{
- float x;
- bool yButton;
- bool aButton;
- bool bButton;
- bool yCooldown;
- bool aCooldown;
- bool bCooldown;
+ float x; /**<The x axis of the joystick*/
+ bool yButton; /**<Whether the y button is pressed*/
+ bool aButton; /**<Whether the a button is pressed*/
+ bool bButton; /**<Whether the b button is pressed*/
+ bool yCooldown; /**<Whether 0.2 seconds has elapsed since the y button was pressed*/
+ bool aCooldown; /**<Whether 0.2 seconds has elapsed since the a button was pressed*/
+ bool bCooldown; /**<Whether 0.2 seconds has elapsed since the b button was pressed*/
};
+
/** MenuSelections struct
-Stores the current selections in both the home menu and death menu.
+*Stores the current selections in both the home menu and death menu.
*/
struct MenuSelections{ //stores the current selections in both menus
- int deathMenuSelection;
- int homeMenuSelection;
+ int deathMenuSelection; /**< Which item in the death screen has been selected*/
+ int homeMenuSelection; /**< Which item in the home screen has been selected*/
};