Controlz 0.3.0
controlz.scm | controlz_demo_windows.zip | controlz_demo_linux.tar.gz |
GitHub repoMove your character with keyboard or joystick controlz for Adventure Game Studio.

This code was originally made by Dualnames for Strangeland and I eri0o got his permission to open source and wrapped in this function to be easier for consumption.
Usage exampleCall it on repeatedly execute, in your Global Script or in the script that you deal with player input, passing a character and some way to check for directional keys, once for each direction (down, left, right, up).
In the example below, WASD will be used to control the player character, and arrow keys will be used to control a second character named cEgo2. Since 0.3.0, solid characters collide with solid characters.
// called on every game cycle, except when the game is blocked
function repeatedly_execute()
{
Controlz(player,
IsKeyPressed(eKeyDownArrow),
IsKeyPressed(eKeyLeftArrow),
IsKeyPressed(eKeyRightArrow),
IsKeyPressed(eKeyUpArrow));
Controlz(cEgo2,
IsKeyPressed(eKeyS), IsKeyPressed(eKeyA),
IsKeyPressed(eKeyD), IsKeyPressed(eKeyW));
}
script APIControlz only has a single function
Controlz(Character* c, bool down, bool left, bool right, bool up)Call it on your repeatedly execute or repeatedly execute always, passing a character and which keys are pressed at that time. If you need to control more characters, just call Controlz again, passing the new character and the buttons that are mapped to move it.
You can check for multiple keys or inputs too.
function repeatedly_execute()
{
Controlz(player,
IsKeyPressed(eKeyDownArrow) || IsKeyPressed(eKeyS),
IsKeyPressed(eKeyLeftArrow) || IsKeyPressed(eKeyA),
IsKeyPressed(eKeyRightArrow) || IsKeyPressed(eKeyD),
IsKeyPressed(eKeyUpArrow) || IsKeyPressed(eKeyW));
}
LicenseThis code is licensed with
MIT LICENSE.