diff --git a/objects/anvil.js b/objects/anvil.js index 8ea5d59..2a5a94a 100644 --- a/objects/anvil.js +++ b/objects/anvil.js @@ -14,6 +14,7 @@ function main() { let nowAt = Self.Position(); if (nowAt.Y > lastPoint.Y) { falling = true; + Self.CameraFollowMe(); } else { falling = false; } diff --git a/regions/Makefile b/regions/Makefile index 1c3f568..890ecf4 100644 --- a/regions/Makefile +++ b/regions/Makefile @@ -23,6 +23,10 @@ build: doodad convert -t "Power Source" power-64.png power-source.doodad doodad install-script power.js power-source.doodad + # Look At Me + doodad convert -t "Look At Me" camera-focus.png camera-focus.doodad + doodad install-script camera-focus.js camera-focus.doodad + # Warp Door doodad convert -t "Invisible Warp Door" warp-door-64.png reg-warp-door.doodad doodad edit-doodad --tag "color=invisible" reg-warp-door.doodad diff --git a/regions/camera-focus.js b/regions/camera-focus.js new file mode 100644 index 0000000..6cacbb2 --- /dev/null +++ b/regions/camera-focus.js @@ -0,0 +1,43 @@ +// Camera Region +// +// When it receives power, it attracts the camera's focus for a while. + +// configuration +const ticksToInsist = 24; + +let powered = false; + +function main() { + Self.Hide(); + + let timer = null; + + Message.Subscribe("power", (v) => { + if (powered && !v) { + // Lost power, we can do this again next time. + powered = false; + if (timer !== null) { + clearInterval(timer); + timer = null; + } + return; + } + + // Look at me! + Self.CameraFollowMe(); + + // And insist a while. + if (timer === null) { + let insistUntil = GetTick() + ticksToInsist; + timer = setInterval(() => { + if (GetTick() < insistUntil) { + Self.CameraFollowMe(); + } else { + clearInterval(timer); + } + }, 10); + } + + powered = v; + }) +} diff --git a/regions/camera-focus.png b/regions/camera-focus.png new file mode 100644 index 0000000..d219673 Binary files /dev/null and b/regions/camera-focus.png differ