HTML and CSS Reference
In-Depth Information
Digital Input
Digital inputs are either on or off. Keys, mouse buttons, digital gamepad buttons are either up or down. Digital inputs
have the following properties:
Digital input id (key code, button id, and so on)
Last time pressed
Last time released
Detecting if a digital button is up or down can be implemented by the following code:
bool get down => lastTimePressed >= lastTimeReleased;
bool get up => lastTimeReleased < lastTimePressed;
Analog Input
Analog inputs have a value inside a limited range (e.g., -1.0 to 1.0 or 0.0 to 1.0). Analog sticks and buttons on
gamepads are examples of analog inputs. Analog inputs have the following properties:
Analog input id (key code, button id, and so on)
Last time updated
Users of analog inputs may want to consider applying a dead zone filter to the value. Dead zone filters cancel
small movements in the analog value by mapping the value back to 0.0. This helps the input feel less twitchy.
Positional Input
Positional inputs are positions in a 2D coordinate system. Mouse cursor and finger positions are examples of
positional inputs. Positional inputs have the following properties:
Positional input id (mouse id, touch id)
X position
Y position
Delta x position
Delta y position
In each frame there may be many positional input values for a specific device. A first person shooter may
accumulate the delta x and delta y position values for the entire frame and use the aggregate to adjust the view angle
of the player. A touch-based game may move a kinematic object through the scene based on the input values.
Game-Specific Code
Mapping from raw input values to game-specific input values allows game controller code to be reconfigured by the
player. The player can decide which button or combination of buttons is used for the jump action (see Figure 20-2 ).
Game-specific inputs are modeled using the same three generalized input types mentioned above, but the state of
these virtual inputs have values set by game-specific code.
Search WWH ::

Custom Search