42 lines
1011 B
Go
42 lines
1011 B
Go
//go:build example
|
|
// +build example
|
|
|
|
package system
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"code.rocketnine.space/tslocum/gohan/examples/twinstick/component"
|
|
|
|
"code.rocketnine.space/tslocum/gohan"
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
|
)
|
|
|
|
type printInfoSystem struct {
|
|
Weapon *component.WeaponComponent
|
|
|
|
img *ebiten.Image
|
|
op *ebiten.DrawImageOptions
|
|
}
|
|
|
|
func NewPrintInfoSystem() *printInfoSystem {
|
|
p := &printInfoSystem{
|
|
img: ebiten.NewImage(200, 100),
|
|
op: &ebiten.DrawImageOptions{},
|
|
}
|
|
p.op.GeoM.Scale(2, 2)
|
|
return p
|
|
}
|
|
|
|
func (s *printInfoSystem) Update(_ gohan.Entity) error {
|
|
return gohan.ErrUnregister
|
|
}
|
|
|
|
func (s *printInfoSystem) Draw(_ gohan.Entity, screen *ebiten.Image) error {
|
|
s.img.Clear()
|
|
ebitenutil.DebugPrint(s.img, fmt.Sprintf("KEY WASD+MOUSE\nENT %d\nUPD %d\nDRA %d\nTPS %0.0f\nFPS %0.0f", gohan.CurrentEntities(), gohan.CurrentUpdates(), gohan.CurrentDraws(), ebiten.CurrentTPS(), ebiten.CurrentFPS()))
|
|
screen.DrawImage(s.img, s.op)
|
|
return nil
|
|
}
|