hot-cocoa-tycoon/system/ui.go

34 lines
810 B
Go

package system
import (
"fmt"
"code.rocketnine.space/tslocum/etk"
"code.rocketnine.space/tslocum/gohan"
"code.rocketnine.space/tslocum/hot-cocoa-tycoon/component"
"code.rocketnine.space/tslocum/hot-cocoa-tycoon/world"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
)
type UISystem struct {
*component.Once
}
func (U *UISystem) Update(e gohan.Entity) error {
return etk.Update()
}
func (U *UISystem) Draw(e gohan.Entity, screen *ebiten.Image) error {
err := etk.Draw(screen)
if err != nil {
return err
}
if world.Debug != 0 {
ebitenutil.DebugPrintAt(screen, fmt.Sprintf("ENT %d\nUPD %d\nDRA %d\nTPS %0.0f\nFPS %0.0f", gohan.CurrentEntities(), gohan.CurrentUpdates(), gohan.CurrentDraws(), ebiten.ActualTPS(), ebiten.ActualFPS()), 2, 0)
}
return nil
}