Helpers

InputAxis

Pure helpers for normalizing boolean directional input into typed axes and movement vectors.

This module is runtime-agnostic: it does not know about keyboard events, gamepads, or host APIs. It only translates already-sampled booleans into the compact movement values used by the examples.

Reach for it in the gap between host input sampling and ECS simulation: capture raw button state in the host, normalize it here, then write the resulting axes or vectors into resources/components for systems to consume.

Examples

// Normalize one sampled host input snapshot into a movement vector.
const movement = InputAxis.vectorFromAxes({
  left: false,
  right: true,
  up: false,
  down: false
})

Axis Helpers

Pure helpers that reduce opposing booleans to one explicit signed movement axis.

axis

Source

Derives one signed axis from two opposing booleans.

Vector Helpers

Runtime-agnostic helpers that derive branded movement vectors from normalized input.

vectorFromAxes

Source

Builds a normalized movement vector from four directional booleans.

const direction = InputAxis.vectorFromAxes({
  left: false,
  right: true,
  up: false,
  down: true
})

vectorFromAxisValues

Source

Builds a normalized movement vector from two explicit axis values.