diff --git a/alui/fonts.go b/alui/fonts.go index e35bede..1ded3b8 100644 --- a/alui/fonts.go +++ b/alui/fonts.go @@ -25,6 +25,8 @@ func (f *Fonts) Destroy() { f.fonts = nil } +func (f *Fonts) Len() int { return len(f.fonts) } + func (f *Fonts) Load(path string, size int, name string) error { font, err := allg5.LoadTTFFont(path, size) if err != nil { diff --git a/cmd/krampus19/game.go b/cmd/krampus19/game.go index 753ae8a..6ebc35b 100644 --- a/cmd/krampus19/game.go +++ b/cmd/krampus19/game.go @@ -64,6 +64,10 @@ func (g *Game) loadFonts() error { if err != nil { return err } + err = g.ui.Fonts().LoadFonts(alui.FontDescription{Path: openSansPath, Name: "steps", Size: 36}) + if err != nil { + return err + } err = g.ui.Fonts().LoadFonts(alui.FontDescription{Path: firaMonoPath, Name: "console", Size: 12}) if err != nil { return err @@ -156,6 +160,7 @@ func (g *Game) loadAssets() error { if err != nil { return err } + log.Printf("Loaded %d fonts.\n", g.ui.Fonts().Len()) log.Println("Loading sprites") // err = g.loadSprites("dragon") diff --git a/cmd/krampus19/playlevel.go b/cmd/krampus19/playlevel.go index 3f3b4e8..71ed6c1 100644 --- a/cmd/krampus19/playlevel.go +++ b/cmd/krampus19/playlevel.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "log" "sort" "time" @@ -331,4 +332,9 @@ func (s *playLevel) Render(ctx *alui.Context, bounds geom.RectangleF32) { crate.DrawOptions(scrPos.X, scrPos.Y, opts) } } + + steps := fmt.Sprintf("STEPS: %d", s.steps) + stepsFont := ctx.Fonts.Get("steps") + stepsWidth := stepsFont.TextWidth(steps) + stepsFont.Draw(.5*(bounds.Dx()-stepsWidth), 24, allg5.NewColor(255, 255, 255), allg5.AlignCenter, steps) }