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.
This commit is contained in:
parent
97e179716c
commit
55efdd6eb5
|
@ -6,6 +6,10 @@ build:
|
||||||
doodad convert -t "Goal Region" goal-128.png reg-goal.doodad
|
doodad convert -t "Goal Region" goal-128.png reg-goal.doodad
|
||||||
doodad install-script goal.js 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
|
# Fire Region
|
||||||
doodad convert -t "Fire Region" fire-128.png reg-fire.doodad
|
doodad convert -t "Fire Region" fire-128.png reg-fire.doodad
|
||||||
doodad install-script fire.js reg-fire.doodad
|
doodad install-script fire.js reg-fire.doodad
|
||||||
|
|
BIN
dev-assets/doodads/regions/checkpoint-128.png
Normal file
BIN
dev-assets/doodads/regions/checkpoint-128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 957 B |
38
dev-assets/doodads/regions/checkpoint.js
Normal file
38
dev-assets/doodads/regions/checkpoint.js
Normal file
|
@ -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;
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
package doodle
|
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
|
// cheatCommand is a subroutine of the Command.Run() method of the Doodle
|
||||||
// developer shell (commands.go). It looks for special cheat codes entered
|
// 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.")
|
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":
|
case "give all keys":
|
||||||
if isPlay {
|
if isPlay {
|
||||||
playScene.Player.AddItem("key-red.doodad", 0)
|
playScene.Player.AddItem("key-red.doodad", 0)
|
||||||
|
|
|
@ -76,10 +76,11 @@ func NewShell(d *Doodle) Shell {
|
||||||
|
|
||||||
// Make the Doodle instance available to the shell.
|
// Make the Doodle instance available to the shell.
|
||||||
bindings := map[string]interface{}{
|
bindings := map[string]interface{}{
|
||||||
"d": d,
|
"d": d,
|
||||||
"RGBA": render.RGBA,
|
"Execute": s.Execute,
|
||||||
"Point": render.NewPoint,
|
"RGBA": render.RGBA,
|
||||||
"Rect": render.NewRect,
|
"Point": render.NewPoint,
|
||||||
|
"Rect": render.NewRect,
|
||||||
"Tree": func(w ui.Widget) string {
|
"Tree": func(w ui.Widget) string {
|
||||||
for _, row := range ui.WidgetTree(w) {
|
for _, row := range ui.WidgetTree(w) {
|
||||||
d.Flash(row)
|
d.Flash(row)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user