-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdebug.go
66 lines (57 loc) · 1.33 KB
/
debug.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2020 Siôn le Roux. All rights reserved.
// Use of this source code is subject to an MIT-style
// licence which can be found in the LICENSE file.
package main
import (
"fmt"
"image/color"
"math"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
)
func debug(screen *ebiten.Image, g *Game) {
ebitenutil.DrawRect(
screen,
float64(g.Width)/2-20,
float64(g.Height)/2-20,
40,
40,
color.RGBA{255, 255, 0, 255},
)
ebitenutil.DrawRect(
screen,
float64(g.Crosshair.Center.X-20),
float64(g.Crosshair.Center.Y-20),
40,
40,
color.RGBA{0, 255, 0, 255},
)
ebitenutil.DrawLine(
screen,
float64(g.Earth.Center.X),
float64(g.Earth.Center.Y),
float64(g.Earth.Center.X)+g.Earth.Radius,
float64(g.Earth.Center.Y),
color.RGBA{255, 0, 0, 255},
)
mx, my := ebiten.CursorPosition()
ebitenutil.DrawLine(
screen,
float64(g.Earth.Center.X),
float64(g.Earth.Center.Y),
float64(mx),
float64(my),
color.RGBA{0, 255, 255, 255},
)
mdx := mx - g.Width/2
mdy := my - g.Height/2
ebitenutil.DebugPrint(screen, fmt.Sprintf("(%v, %v) d%.0f\n",
mdx, mdy,
math.Sqrt(math.Pow(float64(mdx), 2)+math.Pow(float64(mdy), 2)),
))
}
func fps(screen *ebiten.Image) {
ebitenutil.DebugPrint(screen,
fmt.Sprintf("FPS: %.0f, Tick: %.0f\n", ebiten.CurrentFPS(), ebiten.CurrentTPS()),
)
}