gg/cmd/test/debug.go

74 lines
1.5 KiB
Go
Raw Normal View History

2023-12-23 00:09:07 +03:00
package main
2024-05-19 21:11:58 +03:00
import "surdeus.su/core/gg"
2024-06-01 16:07:28 +03:00
import "surdeus.su/core/gg/ox"
import "surdeus.su/core/gg/mx"
2023-12-23 00:09:07 +03:00
import (
//"strings"
//"fmt"
2023-12-23 00:09:07 +03:00
)
type Debug struct {
2024-06-01 16:07:28 +03:00
ox.ObjectImpl
ox.Visibility
}
2024-06-01 16:07:28 +03:00
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()
}
2024-05-19 21:11:58 +03:00
}
2023-12-23 00:09:07 +03:00
}
2024-06-01 22:01:17 +03:00
func (d *Debug) OnStart(c Context) {
d.Visible = true
}
2024-06-01 16:07:28 +03:00
func (d *Debug) GetLayer() gg.Layer {return LayerHighest}
func (d *Debug) Draw(c Context) *gg.Drawing {
e := c.Engine()
2024-01-18 06:06:27 +03:00
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",
2024-05-19 21:11:58 +03:00
"GetRealCursorPosition(...) = ",
e.GetRealCursorPosition(), "\n",
2023-12-24 15:05:34 +03:00
"GetAbsCursorPos(...) = ",
e.GetAbsCursorPosition(), "\n",
2024-06-01 16:07:28 +03:00
"GetAbsWinSize(...) = ",
c.Engine().GetAbsWinSize(), "\n",
2024-06-01 16:07:28 +03:00
)
2023-12-23 00:09:07 +03:00
return nil
2023-12-23 00:09:07 +03:00
}