Added steps counter.
This commit is contained in:
parent
227c451ca6
commit
a6cb582254
@ -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 {
|
||||
|
@ -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")
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user