Apply Inputs
inputs.process.RdUpdates RAM$actions according to any inputs occurring on the current frame.
Inputs and actions are stored in RAM like so:
RAM$inputs | | Stores every input that ever occurred, just like inputs.csv. |
RAM$actions | Stores the game actions corresponding to inputs as dictated in ROM$keybinds (see below). |
Arguments
- RAM
RAM object to update.
Details
The following is an outline of the process from a player entering an input to it being registered by the game.
Player types out "
wa" in theinputs.listen()listener.Player presses Enter; an input is created consisting of the string
"wa"and a timestamp (see inputs.listen).
This input is written toinputs.csv.When the gameloop runs
inputs.get(), this input is added toRAM$inputsand its timestamp is converted to the tick it should be processed on.When
RAM$ticks ==the tick timestamp of this input inRAM$inputs, the input is processed:The input is split into individual characters:
"w"and"a".The actions corresponding to these keys,
RAM$ROM$keybinds["w"] and RAM$ROM$keybinds["a"], are set to1inRAM$actions(see below).Game code in
RAM$ROM$custom()readsRAM$actionsand move the player character accordingly.On the next frame, all
RAM$actionsare set to0before inputs are checked again.
Keybinds
Keybinds are set by the dev with, e.g.
This stores the actions ('attack', 'up', etc.) and the keys (k, w, etc.) that, when input, activate the actions.
These keybinds populate RAM$actions when RAM is initialized:
When a key is registered, the corresponding action in RAM$actions is set to 1 for one frame. (If a key is pressed multiple times in the same input, e.g. "ww", the action will be set to 2, and so on. This is useful for allowing for more input combinations with a single button.)
The game should read RAM$actions to control game behavior; see vignette('rrio') to see this in action.