A camera that trails its target and can be shaken, as a value the game steps.
follow = Cauldron2D.Camera.Follow.new(ship.pos)
follow = follow |> Cauldron2D.Camera.Follow.follow(ship.pos, dt, 0.3) |> Cauldron2D.Camera.Follow.step(dt)
Cauldron2D.Camera.view(focus: Cauldron2D.Camera.Follow.focus(follow), ...)follow/4 closes on the target so that the distance halves every lag seconds; a
lag of 0 snaps to it. shake/3 starts a shake of an amplitude in tiles that
fades to nothing over its time; step/2 advances it. The shake is a fixed pattern
of the time elapsed, so a replay shakes the same way.
Summary
Functions
Where the camera looks: its position plus the shake.
Move toward target for dt seconds, the distance halving every lag seconds.
A camera at pos.
The shake's offset now, {0.0, 0.0} when there is none.
Start a shake of amplitude tiles fading over duration seconds; a shake already going is replaced.
Advance the shake by dt seconds; it ends when its time is up.
Types
Functions
Where the camera looks: its position plus the shake.
Move toward target for dt seconds, the distance halving every lag seconds.
A camera at pos.
The shake's offset now, {0.0, 0.0} when there is none.
Start a shake of amplitude tiles fading over duration seconds; a shake already going is replaced.
Advance the shake by dt seconds; it ends when its time is up.