FollowInputX

class FollowInputX(speed: Double, left: Key, right: Key)

Horizontal motion commanded by the player: the pointer's x is followed absolutely, and the key pair slides while the pointer rests.

A world-owned helper serving one followed entity — the last-input-wins arbitration needs one latched sample across steps, so each follower gets its own instance. Arbitration is decided per call: the pointer commands only when its sampled x differs from the previous call's sample; otherwise the motion is axis * speed * dt over the step's duration, where the axis is +1 with only right held, -1 with only left, and 0 with both or neither — and a call with no pointer at all takes the key path too. The comparison is bit-exact by design — a resting pointer repeats the identical sampled Double, so no tolerance is involved. The motion is unconstrained; clamping it to a region is the caller's business.

Parameters

speed

The keyboard slide speed, in model units per second.

left

The Compose key code sliding toward negative x while held.

right

The Compose key code sliding toward positive x while held.

Constructors

Link copied to clipboard
constructor(speed: Double, left: Key, right: Key)

Builds the follower with its tuning; the latch starts empty, so the first pointer sample counts as moved.

Functions

Link copied to clipboard
context(step: Step)
fun dx(currentX: Double): Double

Returns the step's horizontal displacement for an entity at currentX, advancing the pointer latch.