-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
49 lines (42 loc) · 907 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
41
42
43
44
45
46
47
48
49
package main
import (
"fmt"
"github.com/go-gl/gl"
"github.com/go-gl/glfw"
"github.com/samnm/goblocks/blocks"
"github.com/samnm/goblocks/util/fps"
"os"
)
const (
title = "Goblocks!"
appWidth = 1024
appHeight = 768
)
func main() {
if err := glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "[e] %v\n", err)
return
}
defer glfw.Terminate()
if err := glfw.OpenWindow(appWidth, appHeight, 8, 8, 8, 8, 24, 8, glfw.Windowed); err != nil {
fmt.Fprintf(os.Stderr, "[e] %v\n", err)
return
}
defer glfw.CloseWindow()
if err := gl.Init(); err != 0 {
fmt.Fprintf(os.Stderr, "[e] %v\n", err)
return
}
glfw.SetWindowTitle(title)
fps := fps.NewFPS(glfw.Time())
blocks.Init(appWidth, appHeight)
for glfw.WindowParam(glfw.Opened) == 1 {
blocks.Tick()
fps.Tick(glfw.Time())
if glfw.WindowParam(glfw.Active) == 1 {
glfw.Sleep(0.001)
} else {
glfw.Sleep(0.05)
}
}
}