-
Notifications
You must be signed in to change notification settings - Fork 0
/
ingoio.go
77 lines (67 loc) · 1.3 KB
/
ingoio.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
package main
import (
"github.com/veandco/go-sdl2/sdl"
sdl_ttf "github.com/veandco/go-sdl2/sdl_ttf"
"os"
)
func checkErr(e error) {
if e != nil {
panic(e)
}
}
var (
window *sdl.Window
renderer *sdl.Renderer
windowHeight = 600
windowWidth = 800
scene *Scene
mediaPath string
)
func init() {
mediaPath = os.Getenv("INGOIO_MEDIA")
if mediaPath == "" {
mediaPath = "./res/"
}
}
func main() {
err := sdl.Init(sdl.INIT_EVERYTHING)
checkErr(err)
err = sdl_ttf.Init()
checkErr(err)
window, err = sdl.CreateWindow("InGOio",
0, 0, windowWidth, windowHeight, sdl.WINDOW_SHOWN)
checkErr(err)
renderer, err = sdl.CreateRenderer(window, -1,
sdl.RENDERER_ACCELERATED|sdl.RENDERER_PRESENTVSYNC)
checkErr(err)
defer window.Destroy()
window.SetTitle("InGOio")
drawTitle("InGO io")
sdl.Delay(3000)
scene = newScene()
go func(fps uint32) {
for {
scene.drawFrame()
renderer.Present()
sdl.Delay(1000 / fps)
}
}(30)
running := true
for running {
for event := sdl.PollEvent(); event != nil; event = sdl.WaitEvent() {
switch event.(type) {
case *sdl.QuitEvent:
running = false
break
case *sdl.KeyDownEvent:
handleKeyEvent(event.(*sdl.KeyDownEvent))
}
}
}
sdl.Quit()
// for {
// handleEvents()
// updateStates()
// display()
// }
}