Log inGet started
World

EMBERLINE

Branchmain
Branchesmain
Commite3b1d97d67

README.md

staging.camera

The one thing that moves FightCamera. Registered as Bus.services.camera.

The camera is orthographic and never rotates. Everything it does is three numbers: where it sits on x, where it sits on y, and how much world height it shows (3.4 at its closest, 5.6 when the fighters are at the walls).

Bus.call("camera", "follow", p1.x, p2.x)     -- the fight's resting behaviour
Bus.call("camera", "focus", x, y, 1.8, 20)   -- take it away for a beat
Bus.call("camera", "hold", 90, 40)           -- ...and give it back on its own
Bus.call("camera", "shake", 0.4)
  • follow(x1, x2) keeps both fighters in frame with a margin and widens as they separate. Call it every frame; it is smoothed, not snapped.
  • focus(x, y, zoom, frames) overrides follow for a staged beat. hold(frames, releaseFrames) hands the camera back on its own, so a missed release can never strand the view.
  • shake(mag) is trauma-based: additive, decaying, and squared, so a small value really is small. impulse(dx, dy, tilt) shoves the frame once and lets it spring back — that is what makes a heavy read as a heavy rather than as more shake.
  • lock() / unlock() — while the lock is held, follow is ignored. The attract sequence holds it, because a combat slice calling follow every frame otherwise wins the argument against every staged shot.
  • set / snap place the camera absolutely, for beats with no fighters.

The result is mirrored into Bus.state.camera (x, y, zoom, height, shakeX, shakeY) every frame, so any slice can read the framing without touching the entity.