Input
To get input in your game, you add fields of the correct type in your Input struct:
They can be:
- Button:
Bool- button, digital input, true or false. The API by design do not provide went down, went up. - Stick:
(Float, Float)- “stick” input.
Example:
struct IngameInput {
move: (Float, Float),
fire: Bool,
}
Input Action Sets
In the future we will add support for action sets, e.g. Menu and InGame input, and they will work in a similar way:
struct MyGameInput {
ingame: IngameInput,
menu: MenuInput,
}
only one set can be active at any time.
Input Layers
Also a future thing, where you sometimes want to have “layers” where the player wants to sometimes do two things at once. It is usually rare for smaller games to need this. so we will figure out this in the future.
Bindings
For the fields in your input struct to get any values, you need bindings. If you are using the Steam build of Lily2D, the action names in the .vdf-file must correspond to your field names in your Input struct. For non steam builds — you use Lily2Ds own binding system.
Lily2D bindings
Bindings use the famous .yini file format. Here is an example of a keyboard binding file:
bindings {
# The action set used for ingame
ingame {
# Move the ship around
move {
mode :stick
keys :wasd
}
# Fire laser
fire {
mode :button
key space
}
}
}