Querying Actions
type ActionState = { pressed: boolean; just_pressed: boolean; just_released: boolean; value: number; // for axes; 1 / 0 for digital};
input.pressed("jump"); // booleaninput.just("jump"); // boolean — true ONLY on the tick of the down-edgeinput.released("jump"); // boolean — true ONLY on the tick of the up-edgeinput.axis("move.x"); // number in [-1, 1]input.vector("move.x", "move.y");// readonly [number, number]input.query("jump"); // full ActionStatejust and released are single-tick edges — they fire on exactly one advance() and clear on the next. Don’t latch them yourself.
Inside a system
Section titled “Inside a system”import type { System } from "@f0rbit/forge";
export const player_input_system: System = (w, ctx) => { const [ax, ay] = ctx.input.vector("move.x", "move.y"); for (const [id] of w.query([player_c, vel_c] as const)) { w.set(id, vel_c, { dx: ax * speed, dy: ay * speed }); }};