generated from sionleroux/ebitengine-game-template
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdebugtext.go
39 lines (32 loc) · 922 Bytes
/
debugtext.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Use of this source code is subject to an MIT-style
// licence which can be found in the LICENSE file.
//go:build !release
package main
import (
"fmt"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
)
func init() {
debuggers.Add(DebugFunc(DebugText))
// Uncap FPS so you can see if a code change has had an impact on
// the game's performance
ebiten.SetFPSMode(ebiten.FPSModeVsyncOffMaximum)
}
// DebugText prints out general debug information as text
func DebugText(g *GameScreen, screen *ebiten.Image) {
ebitenutil.DebugPrint(screen, fmt.Sprintf(
"FPS: %.2f\n"+
"TPS: %.2f\n"+
"X: %.2f\n"+
"Y: %.2f\n"+
"Zombies: %d\n"+
"Progress: %.2f%%\n",
ebiten.ActualFPS(),
ebiten.ActualTPS(),
g.Player.Object.Position.X/32,
g.Player.Object.Position.Y/32,
len(g.Zombies),
float64(g.Dog.MainPath.NextPoint)/float64(len(g.Dog.MainPath.Points))*100,
))
}