gg/cmd/test/debug.go

78 lines
1.7 KiB
Go

package main
import "surdeus.su/core/gg"
import "surdeus.su/core/gg/ox"
import "surdeus.su/core/gg/mx"
import (
//"strings"
//"fmt"
)
type Debug struct {
ox.ObjectImpl
ox.Visibility
}
func (d *Debug) OnUpdate(c Context) {
for _, key := range c.Events().Keyboard.KeyDowns {
switch key.Key {
case gg.KeyF11:
d.ToggleVisibility()
//d.Visible = !d.IsVisible()
}
}
}
func (d *Debug) OnStart(c Context) {
d.Visible = true
}
func (d *Debug) GetLayer() gg.Layer {return LayerHighest}
func (d *Debug) Draw(c Context) *gg.Drawing {
e := c.Engine()
relTri := tri.Rel()
relPlayer := player.Rel()
keys := c.Engine().GetKeyboardKeys()
c.Dprint(
"counter = ", counter, "\n",
"tps = ", int(c.Engine().TPS()), "\n",
"fps = ", int(c.Engine().FPS()), "\n",
"dframe = ", int(c.Engine().Dframe()), "\n",
"frame = ", int(c.Engine().Frame()), "\n",
"relPlayerPos = ", relPlayer.GetPosition(), "\n",
"absPlayerPos = ", player.GetPosition(), "\n",
"relTriPos = ", relTri.GetPosition(), "\n",
"absTriPos = ", tri.GetPosition(), "\n",
"absTriRot = " , mx.Degree(tri.GetRotation()), "\n",
"keys = ", keys, "\n",
"GetMouseButtons(...) = ",
c.Engine().GetMouseButtons(), "\n",
"GetMouseWheel(...) = ", "\n",
c.Engine().GetMouseWheel(), "\n",
"camera.GetPosition(...) = ",
camera.GetPosition().X,
camera.GetPosition().Y, "\n",
"GetRealCursorPosition(...) = ",
e.GetRealCursorPosition(), "\n",
"GetAbsCursorPos(...) = ",
e.GetAbsCursorPosition(), "\n",
"GetAbsWinSize(...) = ",
c.Engine().GetAbsWinSize(), "\n",
"ConnectedTriangleAmount = ",
len(c.Engine().Objects().FindByTags(
TagTriangle, TagConnectedToPlayer,
)), "\n",
)
return nil
}