Files
inkwell/core.dsl.go
mr.zeroandClaude Opus 5 e26f7345c1
ci/woodpecker/push/woodpecker Pipeline was successful
OnStart takes a script name, and OnFinale joins it
The opening a game plays was the one piece of content that had to be
assembled in the wiring, because OnStart wanted an Action. It takes the
name of a registered Script now, so an opening is a Script like any
other, and Validate rejects a name that is not there.

OnFinale names the closing script and queues it straight after the start
one — what a "boot into the ending" debug flag wants.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-30 11:25:49 +02:00

55 lines
1.5 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package inkwell
import (
"github.com/hajimehoshi/ebiten/v2"
)
// Run validates the game, then enters the ebiten main loop. The window is
// sized to 4× the internal resolution.
func Run(g *Game) error {
// The domain may have swapped a manager in since NewGame, so the parts
// that hold a registry directly are wired here, not at construction.
g.Audio.attach(g.AssetManager)
if err := g.Validate(); err != nil {
return err
}
// If the domain didn't register any widgets, fall back to the SCUMM
// preset so the game is still playable.
if g.UIManager.Len() == 0 {
RegisterDefaultUI(g)
}
// Initial scene goes in directly (no transition) so OnEnter / OnStart
// run cleanly as one composed sequence on the first script tick.
s := g.SceneManager.MustGet(g.startID)
g.currentScene = g.startID
g.State.NoteVisit(g.startID)
g.placeActors(g.startID)
g.resetTriggers()
if s.Music != "" {
g.Audio.PlayMusic(s.Music)
}
var seq []Action
if s.OnEnter != nil {
seq = append(seq, s.OnEnter)
}
if g.onStart != "" {
seq = append(seq, RunScript(g.onStart))
}
if g.onFinale != "" {
seq = append(seq, RunScript(g.onFinale))
}
if len(seq) > 0 {
g.queueAction(Seq(seq...), "init")
}
ebiten.SetWindowSize(g.Width*4, g.Height*4)
ebiten.SetWindowTitle(g.Title)
ebiten.SetWindowResizingMode(ebiten.WindowResizingModeEnabled)
return ebiten.RunGame(&engine{g: g})
}
// (Game.Run is provided here for convenience; some callers prefer it.)
func (g *Game) Run() error { return Run(g) }