From 55efdd6eb57bcb33d5c838058bed69624988e21b Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sat, 2 Oct 2021 21:12:57 -0700 Subject: [PATCH] Technical Doodad: Checkpoint Region The Checkpoint Region acts as an invisible checkpoint flag, remembering the player's location should they need to respawn there. New cheat: `show all actors` during Play Mode will make every hidden actor visible. Useful to see your technical doodads during gameplay! Developer shell: `Execute(command string)` is available to the JavaScript interpreter. It simulates another command being run on the developer console. --- dev-assets/doodads/regions/Makefile | 4 ++ dev-assets/doodads/regions/checkpoint-128.png | Bin 0 -> 957 bytes dev-assets/doodads/regions/checkpoint.js | 38 ++++++++++++++++++ pkg/cheats.go | 14 ++++++- pkg/shell.go | 9 +++-- 5 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 dev-assets/doodads/regions/checkpoint-128.png create mode 100644 dev-assets/doodads/regions/checkpoint.js diff --git a/dev-assets/doodads/regions/Makefile b/dev-assets/doodads/regions/Makefile index 63b40ad..7d8c6b2 100644 --- a/dev-assets/doodads/regions/Makefile +++ b/dev-assets/doodads/regions/Makefile @@ -6,6 +6,10 @@ build: doodad convert -t "Goal Region" goal-128.png reg-goal.doodad doodad install-script goal.js reg-goal.doodad + # Checkpoint Region + doodad convert -t "Checkpoint Region" checkpoint-128.png reg-checkpoint.doodad + doodad install-script checkpoint.js reg-checkpoint.doodad + # Fire Region doodad convert -t "Fire Region" fire-128.png reg-fire.doodad doodad install-script fire.js reg-fire.doodad diff --git a/dev-assets/doodads/regions/checkpoint-128.png b/dev-assets/doodads/regions/checkpoint-128.png new file mode 100644 index 0000000000000000000000000000000000000000..bc1c34e60934afad5258271a0f2e8f53d6297150 GIT binary patch literal 957 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7xzrU~I{Bb`J1#c2+1T%1_J8No8Qr zm{>c}*5j~)%+dH@S4~lN?GB5S6^{}eLyiQl4rt+87?yGM;FC-G8J8w3*nm5IldZQUej0Ta5>j_YDf3X zH>+-Z?Gj-5k}T46Mkm>C(xeZv@!vTkmQ`2g9BpXuusO|hS?!*}yn9=C z&;33k7&ayJQSl?g$$B1tPLv*fY<`Y)I_o@1!^>7JvJ+ToF(=lyAYIA`CcGo`bfJrV@HCnz{MimFaYRCZhK*VQWW_IT}|=5_H( z)1B4{Nmz;nG_u|N+Wi0E`@FS(p0rFC>0_R&-}l*&r{pbD@2tl)^45NjSvc&N!>dlm zuVgl!zvOyU)EAByciHsTMbFyA9`lZY*}pC4)H;zRnom9-_$^r*EcRkIt5bGd{@L0& zb_|)Xv?`fpWSEp$PsM$&EHAIl|35GD+jnLS*P_l(3HOv?Fsgj;d^HIele;`!978H@y}cD%)MOyi zaPh&8E$>d6?oj`J&CYPL(Vx3huBm;Wb39DoF*}R;<;RadMoQVlpMUu#TlxLP+jZ5p z&u*@rFpFW*>{s6IPbN9$WUHQH_{$J4pCHaE)TPOZqzqc&+cGd4xgRlR;Id#`8oA!41 z4%Ru6AGGD%&%N27I$`>4m-9)*4fQ|n%=#&D&y4-Y%Lh4kA6FNe%=eT(aPi2i?fXC6 zW3J9-u;mG>Wn1Sf@c)%@Pm$<~2J?i!{68!{i*&e+6W9M1B=y7!ke^aC^4`!Ft8+W07(G`CI<#EI1sUh%kRXh zgf5VnK!YM!hJ%4o0W8aqpfIgfJtfk@l>sQmaXTj5Qb}*1*8i2(gr-A!XlR5gEasH!VKN?R~rbdU6@71H+V0ta+=9 U7jI!Zd=#YF)78&qol`;+0A>)JmjD0& literal 0 HcmV?d00001 diff --git a/dev-assets/doodads/regions/checkpoint.js b/dev-assets/doodads/regions/checkpoint.js new file mode 100644 index 0000000..47f5669 --- /dev/null +++ b/dev-assets/doodads/regions/checkpoint.js @@ -0,0 +1,38 @@ +// Checkpoint Region +// Acts like an invisible checkpoint flag. +var isCurrentCheckpoint = false; + +function main() { + Self.Hide(); + setActive(false); + + // Checkpoints broadcast to all of their peers so they all + // know which one is the most recently activated. + Message.Subscribe("broadcast:checkpoint", function (currentID) { + setActive(false); + }); + + Events.OnCollide(function (e) { + if (isCurrentCheckpoint || !e.Settled) { + return; + } + + // Only care about the player character. + if (!e.Actor.IsPlayer()) { + return; + } + + // Set the player checkpoint. + SetCheckpoint(Self.Position()); + setActive(true); + Message.Broadcast("broadcast:checkpoint", Self.ID()) + }); +} + +function setActive(v) { + if (v && !isCurrentCheckpoint) { + Flash("Checkpoint!"); + } + + isCurrentCheckpoint = v; +} \ No newline at end of file diff --git a/pkg/cheats.go b/pkg/cheats.go index 99a19b6..5b3cf44 100644 --- a/pkg/cheats.go +++ b/pkg/cheats.go @@ -1,6 +1,8 @@ package doodle -import "git.kirsle.net/apps/doodle/pkg/balance" +import ( + "git.kirsle.net/apps/doodle/pkg/balance" +) // cheatCommand is a subroutine of the Command.Run() method of the Doodle // developer shell (commands.go). It looks for special cheat codes entered @@ -68,6 +70,16 @@ func (c Command) cheatCommand(d *Doodle) bool { d.Flash("Use this cheat in Play Mode to disable clipping for the player character.") } + case "show all actors": + if isPlay { + for _, actor := range playScene.drawing.Actors() { + actor.Show() + } + d.Flash("All invisible actors made visible.") + } else { + d.Flash("Use this cheat in Play Mode to show hidden actors, such as technical doodads.") + } + case "give all keys": if isPlay { playScene.Player.AddItem("key-red.doodad", 0) diff --git a/pkg/shell.go b/pkg/shell.go index 22117a0..e17a2e5 100644 --- a/pkg/shell.go +++ b/pkg/shell.go @@ -76,10 +76,11 @@ func NewShell(d *Doodle) Shell { // Make the Doodle instance available to the shell. bindings := map[string]interface{}{ - "d": d, - "RGBA": render.RGBA, - "Point": render.NewPoint, - "Rect": render.NewRect, + "d": d, + "Execute": s.Execute, + "RGBA": render.RGBA, + "Point": render.NewPoint, + "Rect": render.NewRect, "Tree": func(w ui.Widget) string { for _, row := range ui.WidgetTree(w) { d.Flash(row)