-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
40 lines (32 loc) · 969 Bytes
/
main.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
package main
import (
"fmt"
"golang.org/x/image/colornames"
"github.com/faiface/pixel"
"github.com/faiface/pixel/pixelgl"
)
func run() {
//pixelgl.WindowConfig is a struct that lets us do the initial config of a window
//setting Vsync=true will enable the win.Update to follow the displays refresh interval,
//so it does not consume all the cpu by running constantly and as fast as it can.
cfg := pixelgl.WindowConfig{
Title: "test window",
Bounds: pixel.R(0, 0, 500, 500),
VSync: true,
}
//create the new window
win, err := pixelgl.NewWindow(cfg)
if err != nil {
fmt.Println("error: Creating window : ", err)
panic(err)
}
win.Clear(colornames.Skyblue)
//create a loop that keeps the window open, unless the close button in the corner is pushed
//The function win.Update fetches new events (key presses, mouse moves and clicks, etc.) and redraws the window.
for !win.Closed() {
win.Update()
}
}
func main() {
pixelgl.Run(run)
}