Skip to reading
Adventure Mechanics & Effects

Read a tap separately from a hold

Edition 0.86.3.4

Build authored boxing, camera moves, weather, attachments, inspectable objects, a radio and two-object puzzles using the existing adventure tools and scripts.

Download PDFView PDF page

LIVE BOXING SCRIPT / C OF G

Append both functions. The order of keys in held remembers the most recent guard. Physical key codes use the positions of WASD on a QWERTY keyboard.

Code example
func _input(e: InputEvent) -> void:
    if not live or not (e is InputEventKey) or suspended():
        return
    var k = e.physical_keycode
    if k not in [KEY_W, KEY_S, KEY_A, KEY_D, KEY_Q]:
        return
    get_viewport().set_input_as_handled()
    if e.echo:
        return
    if k in [KEY_A, KEY_D]:
        held.erase(k)
        if e.pressed:
            held.append(k)
        if fighters[0].age >= READY:
            defend(0, player_guard())
    elif e.pressed and k == KEY_Q:
        finish("You stepped away.")
    elif e.pressed and fighters[0].age >= READY:
        punch(0, "high" if k == KEY_W else "low")
Code example
func player_guard():
    if held.is_empty():
        return ""
    return "high" if held.back() == KEY_A else "low"

Press A, press D, release D. The remaining entry is A, so the high guard returns. Punches ignore the keyboard’s automatic key repeat. To start another punch, release the key and tap again after recovery.

Page 23 of 29Permalink
Go to page