gizgame/feel
AAA Game Feel & Juice kernel: action frame-data state machine (startup/active/recovery/cancel), input buffering, coyote time, hitstop/time-dilation curves, and trauma-based camera feel.
import * as Feel from "gizgame/feel";Types
ActionSpec
type ActionSpec = { name: string; startup: f64; active: f64; recovery: f64; cancelAfter: f64; }Timing windows (in seconds) for a melee swing, dodge, parry, or skill action.
name:stringstartup:f64active:f64recovery:f64cancelAfter:f64
ActionState
type ActionState = { spec: ActionSpec; elapsed: f64; phase: string; hitApplied: bool; }Live execution state of an action. Phase is "idle", "startup", "active", or "recovery".
spec:M222.ActionSpecelapsed:f64phase:stringhitApplied:bool
InputBuffer
type InputBuffer = { action: string; remaining: f64; }Single-slot input buffer so inputs pressed slightly before recovery end fire on the first legal frame.
action:stringremaining:f64
Coyote
type Coyote = { remaining: f64; window: f64; }Coyote-time grace window allowing fair jumps shortly after leaving a ledge.
remaining:f64window:f64
Hitstop
type Hitstop = { remaining: f64; scale: f64; }Hitstop and slow-motion time-dilation controller for heavy impacts and parries.
remaining:f64scale:f64
CameraFeel
type CameraFeel = { trauma: f64; decay: f64; baseFov: f64; fov: f64; fovTarget: f64; }Trauma-based camera shake and FOV kick spring.
trauma:f64decay:f64baseFov:f64fov:f64fovTarget:f64
Functions
idleAction
function idleAction(): ActionStateAn action that does nothing: no swing is in hand.
startAction
function startAction(spec: ActionSpec): ActionStateBegins an action from frame 0.
stepAction
function stepAction(st: ActionState, dt: f64): ActionStateAdvances an action by dt and updates its phase.
canCancel
function canCancel(st: ActionState): boolReturns true when the current action can be canceled into a dodge, parry, or combo link.
emptyBuffer
function emptyBuffer(): InputBufferA buffer that holds no input.
bufferInput
function bufferInput(action: string, windowSeconds: f64 = 0.12): InputBufferA buffer that holds ACTION for WINDOWSECONDS.
stepBuffer
function stepBuffer(buf: InputBuffer, dt: f64): InputBufferBUF after DT seconds: empty once its window is over.
consumeBuffered
function consumeBuffered(buf: InputBuffer, action: string): { matched: bool; buffer: InputBuffer }Consumes the buffered action if it matches and is still live.
makeCoyote
function makeCoyote(windowSeconds: f64 = 0.10): CoyoteA grace window of WINDOWSECONDS, not yet open.
stepCoyote
function stepCoyote(c: Coyote, grounded: bool, dt: f64): CoyoteC after DT seconds: the window opens whole on the ground and runs down in the air.
canCoyoteJump
function canCoyoteJump(c: Coyote): boolWhether a jump is still fair after the ledge.
noHitstop
function noHitstop(): HitstopNo stop: time runs at its own rate.
triggerHitstop
function triggerHitstop(seconds: f64 = 0.06, scale: f64 = 0.05): HitstopA stop of SECONDS in which time runs at SCALE (0 to 1) of its rate.
stepHitstop
function stepHitstop(h: Hitstop, rawDt: f64): { state: Hitstop; simDt: f64 }H after RAWDT seconds, and SIMDT: the time the simulation steps in them.
makeCameraFeel
function makeCameraFeel(baseFov: f64 = 1.15, decay: f64 = 1.8): CameraFeelA camera at rest at BASEFOV whose trauma falls by DECAY a second.
addTrauma
function addTrauma(c: CameraFeel, amount: f64): CameraFeelC with AMOUNT more trauma, at most 1.
kickFov
function kickFov(c: CameraFeel, delta: f64): CameraFeelC whose view opens by DELTA; stepCameraFeel eases it there.
stepCameraFeel
function stepCameraFeel(c: CameraFeel, dt: f64): { feel: CameraFeel; shake: f64 }Advances camera trauma and FOV spring, returning quadratic shake intensity in [0, 1].