From 4d960f4d2dcd233f2de5a88b7de892bad1ac5015 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sat, 24 Sep 2022 23:55:30 -0700 Subject: [PATCH] Anvil and Camera Focus doodads --- objects/anvil.js | 1 + regions/Makefile | 4 ++++ regions/camera-focus.js | 43 +++++++++++++++++++++++++++++++++++++++ regions/camera-focus.png | Bin 0 -> 910 bytes 4 files changed, 48 insertions(+) create mode 100644 regions/camera-focus.js create mode 100644 regions/camera-focus.png 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 0000000000000000000000000000000000000000..d219673999ca2f6a1a5baed5c1cdabaaacee5373 GIT binary patch literal 910 zcmV;919AL`P)EX>4Tx04R}tkv&MmKpe$i(~4Cp3U*L&$WWauh>AFB6^c-y)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfbaGO3krMxx6k5c1aNLh~_a1le0HI!Hsu>suRLwF{ z@tBy&u8N(n=)xcZ=tEFqraqTUCg3@~?&0I>U6f~epZjz4C^?e>K9P8q>4rtTK|H-_ z>74h8!>lMN#OK6g23?T&k?XR{Z=4Gb3p_Jyq*L?6VPdh+#&R38qM;H`5l0kNqkJLb zvch?bvs$jQ<~{ifLpg0_nd>x%5yv8ykc0>sRg_SMg($5WDJD|1AM@}JIsPQMWO9|j z$gzM5R7j2={11M2Yvv~>+@w$p=y2C8-O}Ve;Bp5Tc+w?9awI=ZA)g1{&*+=7K>sb!z2^4T+{ftykfyE@H^9Lm zFj}DOb&q!k+k5->OtZfq3W0KcsbXZ}00006VoOIv0RI600RN!9r;`8x010qNS#tmY z3ljhU3ljkVnw%H_000McNliru<_Q@EI20#Ff;IpE0gFjQK~#9!?VC#yf-nq*Q>HVx z^C+H0*PMaFcm~#Z6|dn9V5KW(Sb#Q7(o*_o=`eYGNlVhA>$~<%5po}9$9bM>$6Eha z8me5X2jG^a!!5f~Wf?P;000000000006@Lsl^Tl+5j___-R{Huko5AYnldj8d}{z1 z`>qWNWJ^b?4%I~lekGz>B*Ahh_k{!LJ37Y6Q0e@Q%&!_qh-qEBlHG1ZNREH`81l znh->Rz*yOA_U6!<9ZOqYGb?@9o`~oy)cHzT zSzb9?6A?}51T*#(+zr|vC2;d4kh5#s+5|Ox^0j5W_&q?o67h*l3DX>R&fqjoI1m8< z000000Dyu-`)r`d3eY?x@g;vN{Oh{Csy#qb5r;SrkW{cwZE$ZBC0>I70000000000 k0002Bio>6$u>|Ut4{}-IS=`vV761SM07*qoM6N<$f;okQtpET3 literal 0 HcmV?d00001