-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender.go
47 lines (37 loc) · 834 Bytes
/
render.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
package main
import (
pixel "github.com/faiface/pixel"
imdraw "github.com/faiface/pixel/imdraw"
pgl "github.com/faiface/pixel/pixelgl"
cnames "golang.org/x/image/colornames"
)
func Run() {
config := pgl.WindowConfig{
Title: "Samo Game of Life",
Bounds: pixel.R(0, 0, SCREEN_W, SCREEN_H),
VSync: true,
//AlwaysOnTop: true,
TransparentFramebuffer: true,
}
window, err := pgl.NewWindow(config)
if err != nil {
panic(err)
}
imd := imdraw.New(nil)
grid := NewGrid(ROWS, COLS)
for ! window.Closed() {
window.Clear(cnames.Lightslategrey)
if ! grid.IsSetup() {
if window.Pressed(pgl.MouseButtonLeft) {
grid.Plot(imd, window.MousePosition())
}
if window.Pressed(pgl.KeySpace) {
grid.FinishedSetup()
}
} else {
UpdateGrid(imd, grid)
}
imd.Draw(window)
window.Update()
}
}