-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw.go
113 lines (93 loc) · 1.7 KB
/
draw.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package main
import (
"fmt"
"github.com/gen2brain/raylib-go/raygui"
rl "github.com/gen2brain/raylib-go/raylib"
)
func (g *Game) RenderGUI() {
ui := &g.GUI
if devel {
for i := range ui.grid {
for j := range ui.grid[i] {
r := ui.grid[i][j]
rl.DrawRectangleLinesEx(r, 0.4, rl.Red)
rl.DrawText(
fmt.Sprintf("x:%v,y:%v", i, j),
rint(r.X),
rint(r.Y),
20,
rl.White,
)
}
}
}
ui.Play = raygui.Button(ui.grid[0][3], "Play")
if devel {
ui.Settings = raygui.Button(ui.grid[0][5], "Settings")
}
rl.DrawText("PONG", rint(ui.grid[2][2].X), rint(ui.grid[2][2].Y), 140, rl.White)
rl.DrawText("By Tom5521", rint(ui.grid[2][5].X), rint(ui.grid[2][5].Y), 30, rl.Gray)
muteTxt := "Mute"
if *g.Options.Muted {
muteTxt = "Muted"
}
if devel {
*g.Options.Muted = raygui.Toggle(ui.grid[0][7], muteTxt, *g.Options.Muted)
} else {
*g.Options.Muted = raygui.Toggle(ui.grid[0][5], muteTxt, *g.Options.Muted)
}
if ui.Play {
g.Options.Waiting4Play = true
g.GUI.Visible = false
g.ResetInstances()
}
}
func (g *Game) DrawBackground() {
rl.ClearBackground(rl.DarkGreen)
// Draw window borders
rl.DrawRectangleLinesEx(
rl.Rectangle{
Width: Width,
Height: Height,
},
10,
rl.White,
)
// Draw center-line
rl.DrawLineEx(
rl.Vector2{
X: Width / 2,
Y: 0,
},
rl.Vector2{
X: Width / 2,
Y: Height,
},
10,
rl.White,
)
}
func (g *Game) Draw() {
g.DrawBackground()
if devel {
rl.DrawLine(
0,
Height/2,
Width,
Height/2,
rl.DarkGray,
)
rl.DrawFPS(11, 11)
}
if g.GUI.Visible {
g.Ball.Draw()
g.RenderGUI()
return
}
for _, t := range g.Texts.Texts {
t.Draw()
}
for _, d := range g.Drawers {
d.Draw()
}
}