This commit is contained in:
Josh Deprez 2021-08-27 14:12:31 +10:00
parent 5b457eded1
commit 8e1ddae1d9
3 changed files with 6 additions and 4 deletions

View file

@ -3,6 +3,7 @@ package engine
import (
"encoding/gob"
"fmt"
"image"
"math"
"github.com/hajimehoshi/ebiten/v2"
@ -23,6 +24,7 @@ func init() {
type DebugToast struct {
ID
Hidden
Pos image.Point
Timer int // ticks
Text string
}
@ -31,7 +33,7 @@ func (d *DebugToast) Draw(screen *ebiten.Image, _ ebiten.DrawImageOptions) {
if d.Hidden {
return
}
ebitenutil.DebugPrintAt(screen, d.Text, 0, 20)
ebitenutil.DebugPrintAt(screen, d.Text, d.Pos.X, d.Pos.Y)
}
func (d *DebugToast) DrawOrder() float64 {

View file

@ -77,7 +77,7 @@ func (aw *Awakeman) Update() error {
}
// aw.Pos is top-left corner, so add half size to get centre
aw.camera.Centre = aw.Pos.Add(aw.Size.Div(2))
return nil
return aw.Sprite.Update()
}
func (aw *Awakeman) noclipUpdate() error {
@ -185,7 +185,7 @@ func (aw *Awakeman) realUpdate() error {
aw.vy = 0
}
})
return aw.Sprite.Update()
return nil
}
func (aw *Awakeman) Prepare(game *engine.Game) {

View file

@ -37,7 +37,7 @@ func main() {
ID: "game_camera",
Scene: &engine.SceneRef{Path: "assets/level1.gobz"},
},
&engine.DebugToast{ID: "toast"},
&engine.DebugToast{ID: "toast", Pos: image.Pt(0, 20)},
engine.PerfDisplay{},
},
},