-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
46 lines (42 loc) · 785 Bytes
/
main.go
File metadata and controls
46 lines (42 loc) · 785 Bytes
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
package main
import (
"github.com/fatih/color"
"github.com/veandco/go-sdl2/sdl"
"github.com/veandco/go-sdl2/ttf"
"log"
"math/rand"
"os"
"time"
)
func init() {
rand.Seed(time.Now().UnixNano())
color.NoColor = false
}
func InitSDL() (*sdl.Renderer, *ttf.Font) {
// init SDL systems
sdl.Init(sdl.INIT_EVERYTHING)
err := ttf.Init()
if err != nil {
panic(err)
}
// get renderer
r, rendererError := GetRenderer()
if rendererError != 0 {
log.Fatalf("failed to build renderer (reason %d)\n", rendererError)
}
// get font
f, err := GetFont()
if err != nil {
log.Fatalf("couldn't load font: %v\n", err)
}
return r, f
}
func main() {
var exitcode int
sdl.Main(func() {
r, f := InitSDL()
g := NewGame(r, f)
exitcode = g.gameloop()
})
os.Exit(exitcode)
}