Noah Petherbridge
1ac85c9297
* 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.
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package scripting
|
|
|
|
import "git.kirsle.net/go/render"
|
|
|
|
/*
|
|
RegisterEventHooks attaches the supervisor level event hooks into a JS VM.
|
|
|
|
Names registered:
|
|
|
|
- EndLevel(): for a doodad to exit the level. Panics if the OnLevelExit
|
|
handler isn't defined.
|
|
*/
|
|
func RegisterEventHooks(s *Supervisor, vm *VM) {
|
|
vm.Set("EndLevel", func() {
|
|
if s.onLevelFail == nil {
|
|
panic("JS FailLevel(): No OnLevelFail handler attached to script supervisor")
|
|
}
|
|
s.onLevelExit()
|
|
})
|
|
vm.Set("FailLevel", func(message string) {
|
|
if s.onLevelFail == nil {
|
|
panic("JS FailLevel(): No OnLevelFail handler attached to script supervisor")
|
|
}
|
|
s.onLevelFail(message)
|
|
})
|
|
vm.Set("SetCheckpoint", func(p render.Point) {
|
|
if s.onSetCheckpoint == nil {
|
|
panic("JS SetCheckpoint(): No OnSetCheckpoint handler attached to script supervisor")
|
|
}
|
|
s.onSetCheckpoint(p)
|
|
})
|
|
}
|
|
|
|
// OnLevelExit registers an event hook for when a Level Exit doodad is reached.
|
|
func (s *Supervisor) OnLevelExit(handler func()) {
|
|
s.onLevelExit = handler
|
|
}
|
|
|
|
// OnLevelFail registers an event hook for level failures (doodads killing the player).
|
|
func (s *Supervisor) OnLevelFail(handler func(string)) {
|
|
s.onLevelFail = handler
|
|
}
|
|
|
|
// OnSetCheckpoint registers an event hook for setting player checkpoints.
|
|
func (s *Supervisor) OnSetCheckpoint(handler func(render.Point)) {
|
|
s.onSetCheckpoint = handler
|
|
}
|