Documentation ¶
Overview ¶
Package gamepad provides game controller logic for the game.
Controls ¶
The gamepad controls are currently hard-coded for Xbox 360 style controllers, and the controller mappings vary depending on the "mode" of control.
N Style and X Style ¶
If the gamepad control is set to "NStyle" then the A/B and X/Y buttons will be swapped to match the labels of a Nintendo style controller. Since the game has relatively few inputs needed now, this module maps them to a PrimaryButton and a SecondaryButton, defined as:
PrimaryButton: A or X button SecondaryButton: B or Y button
Mouse Mode ¶
- Left stick moves the mouse cursor (a cursor sprite is drawn on screen) - Right stick scrolls the level (title screen or level editor) - PrimaryButton emulates a left click. - SecondaryButton emulates a right click. - Left Shoulder emulates a middle click. - Left Trigger (L2) closes the top-most window in the Editor (Backspace key) - Right Shoulder toggles between Mouse Mode and other scene-specific mode.
Gameplay Mode ¶
- Left stick moves the player character (left/right only). - D-Pad also moves the player character (left/right only). - PrimaryButton is to "Use" - SecondaryButton is to "Jump" - If the player has antigravity, up/down controls on left stick or D-Pad work too. - Right Shoulder toggles between GameplayMode and MouseMode.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // PlayScene tells us whether antigravity is on, so directional controls work all directions. PlayModeAntigravity bool SceneName string // Set by doodle.Goto() so we know what scene name we're on. )
Global state variables for gamepad support.
Functions ¶
func PrimaryButton ¶
func PrimaryButton(ctrl event.GameController) bool
PrimaryButton returns whether the A or X button is pressed.
func SecondaryButton ¶
func SecondaryButton(ctrl event.GameController) bool
SecondaryButton returns whether the B or Y button is pressed.
func SetControllerIndex ¶
func SetControllerIndex(index int)
SetControllerIndex sets which gamepad will be "Player One"