Talos docs

AxisParts

Since 0.6

One axis action this tick, split by the kind of motion that produced it (ctx.input.axisParts).

Plain text

A stick is a rate: held, it keeps turning, so a camera multiplies it by a speed and dt. A mouse is a displacement: the hand moved so far this tick, so a camera turns by exactly that angle, once. Folding both into one -1..1 number is what axis does, and what caps a flick.

Signature

export interface AxisParts {
  /** Keys, sticks, triggers, the wheel and `POST /input` holds: -1..1 times the action's `sensitivity`. Multiply by a speed and `dt`. */
  rate: Vec2
  /**
   * The mouse's motion this tick as an angle in **degrees**: pixels times the action's
   * `sensitivity` (0.1°/px when it gives none). +x right, +y up. Add it once; never multiply
   * by `dt`, never clamp it. Zero when the action binds no mouse `delta`.
   */
  delta: Vec2
}

Import: import type { AxisParts } from "@argus/api"

Members

MemberSignatureDescription
raterate: Vec2Keys, sticks, triggers, the wheel and POST /input holds: -1..1 times the action's sensitivity. Multiply by a speed and dt.
deltadelta: Vec2The mouse's motion this tick as an angle in degrees: pixels times the action's sensitivity (0.1°/px when it gives none). +x right, +y up. Add it once; never multiply by dt, never clamp it. Zero when the action binds no mouse delta.

Example

The tested fixture fixtures/app/noisy.ts.

import type { Behavior } from "@argus/api"

// Calls into the Ctx surfaces this build records but does not yet act on: particles, HUD and
// labels. `tests/queues.rs` runs it to prove those recordings are bounded — a queue nobody
// drains has to be emptied each frame, or a behavior that emits every tick leaks.
export default {
  init(ctx) {
    ctx.state.ticks = 0
  },
  update(ctx) {
    const n = (ctx.state.ticks as number) + 1
    ctx.state.ticks = n
    ctx.particles.emit("dust", ctx.entity.position, { rate: 4 })
    ctx.hud.set("score", n)
    ctx.labels.set("here", "goal.hazard", ctx.entity.position)
    // A sound no asset registers: the one call above that the engine really cannot act on, so
    // `unwired` has something non-zero for the HTTP test to compare against.
    ctx.audio.play("no-such-sound")
  },
} satisfies Behavior