Files
2026-09-26 16:32:40 +03:00

54 lines
941 B
Go

package demos
import (
"slices"
"aego/engine"
"aego/platform"
)
type Demo interface {
engine.App
Name() string
}
type Configurer interface {
Configure(*engine.Config)
}
type Metric struct {
Name string
Value float64
}
type MetricsReporter interface {
ReportMetrics(dst []Metric) []Metric
}
var Registry = map[string]func() Demo{}
func Register(name string, ctor func() Demo) {
if _, dup := Registry[name]; dup {
panic("demos: duplicate demo name " + name)
}
Registry[name] = ctor
}
func Names() []string {
out := make([]string, 0, len(Registry))
for n := range Registry {
out = append(out, n)
}
slices.Sort(out)
return out
}
type Base struct{}
func (Base) Init(*engine.Engine) error { return nil }
func (Base) Event(platform.Event) {}
func (Base) FixedUpdate(float64) {}
func (Base) Update(float64) {}
func (Base) Render(float64) {}
func (Base) Shutdown() {}