https://github.com/ericoporto/controlz
Move your character with keyboard or joystick controlz for Adventure Game Studio.
https://github.com/ericoporto/controlz
adventure-game-studio adventuregamestudio ags ags-script gamepad keyboard
Last synced: 3 months ago
JSON representation
Move your character with keyboard or joystick controlz for Adventure Game Studio.
- Host: GitHub
- URL: https://github.com/ericoporto/controlz
- Owner: ericoporto
- License: mit
- Created: 2019-08-26T23:43:42.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-06-23T23:52:20.000Z (almost 2 years ago)
- Last Synced: 2025-01-22T07:44:11.082Z (over 1 year ago)
- Topics: adventure-game-studio, adventuregamestudio, ags, ags-script, gamepad, keyboard
- Language: AGS Script
- Homepage: https://www.adventuregamestudio.co.uk/forums/index.php?topic=57427.0
- Size: 1.52 MB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.bbcode
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[size=18pt][b]Controlz[/b][/size] [b][color=gray]0.4.0[/color][/b]
[url="https://github.com/ericoporto/controlz/actions"][img]https://github.com/ericoporto/controlz/actions/workflows/main.yml/badge.svg[/img][/url]
[b][url=https://github.com/ericoporto/controlz/releases/download/v0.4.0/controlz.scm]controlz.scm[/url] | [url=https://github.com/ericoporto/controlz/releases/download/v0.4.0/controlz_demo_windows.zip]controlz_demo_windows.zip[/url] | [url=https://github.com/ericoporto/controlz]GitHub repo[/url]
Move your character with keyboard or joystick controlz for Adventure Game Studio.
[img]https://github.com/ericoporto/controlz/raw/master/controlz_demo.gif[/img]
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.
[size=12pt][size=14pt][b]Usage example[/b][/size][/size]
Call 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. Since 0.4.0, a character will keep walking in place if a button is pressed.
[code=ags]
// 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));
}
[/code]
[size=12pt][size=14pt][b]script API[/b][/size][/size]
Controlz only has a single function
[size=12pt][font=courier]Controlz(Character* c, bool down, bool left, bool right, bool up)[/font][/size]
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.
[code=ags]
function repeatedly_execute()
{
Controlz(player,
IsKeyPressed(eKeyDownArrow) || IsKeyPressed(eKeyS),
IsKeyPressed(eKeyLeftArrow) || IsKeyPressed(eKeyA),
IsKeyPressed(eKeyRightArrow) || IsKeyPressed(eKeyD),
IsKeyPressed(eKeyUpArrow) || IsKeyPressed(eKeyW));
}[/code]
[size=12pt][size=14pt][b]License[/b][/size][/size]
This code is licensed with[url=https://github.com/ericoporto/controlz/blob/master/LICENSE] MIT LICENSE[/url].