Checkpoint Flag & Retry from Checkpoint

* New Doodad: Checkpoint Flag. They update the player's spawn point
  whenever the player passes one. The most recently activated
  checkpoint is rendered brighter than the others.
* End Level Modal: the fake alert box window drawn by the Play Mode
  is replaced with a fancy modal widget (similar to Alert and Confirm).
  It handles level victory or failure conditions and can show or hide
  all the buttons as needed.
* Gameplay: There is a "Retry from Checkpoint" option added, which
  appears in the level failure modal. It will teleport you back to
  the Start Flag or the last Checkpoint Flag you had touched, without
  resetting the level -- your keys, unlocked doors, etc. will be
  preserved so you can retry.
* Set a maximum speed on the "Camera Follows Actor" logic of 64
  pixels per tick. This results in a smoother scrolling transition
  when the player jumps to a new location on the map, such as by
  a Warp Door.
* Update the default color palettes:
    * All: Add a "hint" magenta color.
    * Colored Pencil: Add a "darkstone" solid color.

Updates to the Doodads JavaScript API:

* SetCheckpoint(Point(x, y)): set the player character's spawn
  position. Giving it Self.Position() is an easy way to set the
  player spawn to your doodad's location.
master
Noah 2021-08-15 20:17:53 -07:00
parent 2e8617e8d3
commit 5de48b13f5
5 changed files with 45 additions and 2 deletions

View File

@ -2,7 +2,7 @@ function main() {
var pressed = false;
// When a sticky button receives power, it pops back up.
Message.Subscribe("power", function(powered) {
Message.Subscribe("power", function (powered) {
if (powered && pressed) {
Self.ShowLayer(0);
pressed = false;
@ -12,7 +12,7 @@ function main() {
}
})
Events.OnCollide(function(e) {
Events.OnCollide(function (e) {
if (!e.Settled) {
return;
}

View File

@ -10,6 +10,11 @@ build:
doodad convert -t "Exit Flag" exit-flag.png exit-flag.doodad
doodad install-script exit-flag.js exit-flag.doodad
# Checkpoint Flag
doodad convert -t "Checkpoint Flag" checkpoint-active.png \
checkpoint-inactive.png checkpoint-flag.doodad
doodad install-script checkpoint-flag.js checkpoint-flag.doodad
# Anvil
doodad convert -t "Anvil" anvil.png anvil.doodad
doodad install-script anvil.js anvil.doodad

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

@ -0,0 +1,38 @@
// Checkpoint Flag.
var isCurrentCheckpoint = false;
function main() {
Self.SetHitbox(22 + 16, 16, 75 - 16, 86);
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 (!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;
Self.ShowLayerNamed(v ? "checkpoint-active" : "checkpoint-inactive");
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB