# 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.

```gizlang
import * as Feel from "gizgame/feel";
```

## Types

### `ActionSpec`

```gizlang
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`: `string`
- `startup`: `f64`
- `active`: `f64`
- `recovery`: `f64`
- `cancelAfter`: `f64`

### `ActionState`

```gizlang
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.ActionSpec`
- `elapsed`: `f64`
- `phase`: `string`
- `hitApplied`: `bool`

### `InputBuffer`

```gizlang
type InputBuffer = { action: string; remaining: f64; }
```

Single-slot input buffer so inputs pressed slightly before recovery end fire on the first legal frame.

- `action`: `string`
- `remaining`: `f64`

### `Coyote`

```gizlang
type Coyote = { remaining: f64; window: f64; }
```

Coyote-time grace window allowing fair jumps shortly after leaving a ledge.

- `remaining`: `f64`
- `window`: `f64`

### `Hitstop`

```gizlang
type Hitstop = { remaining: f64; scale: f64; }
```

Hitstop and slow-motion time-dilation controller for heavy impacts and parries.

- `remaining`: `f64`
- `scale`: `f64`

### `CameraFeel`

```gizlang
type CameraFeel = { trauma: f64; decay: f64; baseFov: f64; fov: f64; fovTarget: f64; }
```

Trauma-based camera shake and FOV kick spring.

- `trauma`: `f64`
- `decay`: `f64`
- `baseFov`: `f64`
- `fov`: `f64`
- `fovTarget`: `f64`

## Functions

### `idleAction`

```gizlang
function idleAction(): ActionState
```

An action that does nothing: no swing is in hand.

### `startAction`

```gizlang
function startAction(spec: ActionSpec): ActionState
```

Begins an action from frame 0.

### `stepAction`

```gizlang
function stepAction(st: ActionState, dt: f64): ActionState
```

Advances an action by dt and updates its phase.

### `canCancel`

```gizlang
function canCancel(st: ActionState): bool
```

Returns true when the current action can be canceled into a dodge, parry, or combo link.

### `emptyBuffer`

```gizlang
function emptyBuffer(): InputBuffer
```

A buffer that holds no input.

### `bufferInput`

```gizlang
function bufferInput(action: string, windowSeconds: f64 = 0.12): InputBuffer
```

A buffer that holds ACTION for WINDOWSECONDS.

### `stepBuffer`

```gizlang
function stepBuffer(buf: InputBuffer, dt: f64): InputBuffer
```

BUF after DT seconds: empty once its window is over.

### `consumeBuffered`

```gizlang
function consumeBuffered(buf: InputBuffer, action: string): { matched: bool; buffer: InputBuffer }
```

Consumes the buffered action if it matches and is still live.

### `makeCoyote`

```gizlang
function makeCoyote(windowSeconds: f64 = 0.10): Coyote
```

A grace window of WINDOWSECONDS, not yet open.

### `stepCoyote`

```gizlang
function stepCoyote(c: Coyote, grounded: bool, dt: f64): Coyote
```

C after DT seconds: the window opens whole on the ground and runs down in the air.

### `canCoyoteJump`

```gizlang
function canCoyoteJump(c: Coyote): bool
```

Whether a jump is still fair after the ledge.

### `noHitstop`

```gizlang
function noHitstop(): Hitstop
```

No stop: time runs at its own rate.

### `triggerHitstop`

```gizlang
function triggerHitstop(seconds: f64 = 0.06, scale: f64 = 0.05): Hitstop
```

A stop of SECONDS in which time runs at SCALE (0 to 1) of its rate.

### `stepHitstop`

```gizlang
function stepHitstop(h: Hitstop, rawDt: f64): { state: Hitstop; simDt: f64 }
```

H after RAWDT seconds, and SIMDT: the time the simulation steps in them.

### `makeCameraFeel`

```gizlang
function makeCameraFeel(baseFov: f64 = 1.15, decay: f64 = 1.8): CameraFeel
```

A camera at rest at BASEFOV whose trauma falls by DECAY a second.

### `addTrauma`

```gizlang
function addTrauma(c: CameraFeel, amount: f64): CameraFeel
```

C with AMOUNT more trauma, at most 1.

### `kickFov`

```gizlang
function kickFov(c: CameraFeel, delta: f64): CameraFeel
```

C whose view opens by DELTA; stepCameraFeel eases it there.

### `stepCameraFeel`

```gizlang
function stepCameraFeel(c: CameraFeel, dt: f64): { feel: CameraFeel; shake: f64 }
```

Advances camera trauma and FOV spring, returning quadratic shake intensity in [0, 1].

