-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
50 lines (40 loc) · 1 KB
/
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
50
package main
// Pack all assets into pkged.go for single file distribution.
//
//go:generate go get github.com/markbates/pkger/cmd/pkger
//go:generate pkger -include /assets
import (
"github.com/hajimehoshi/ebiten"
"github.com/mlesniak/speedrun/internal/seed"
"log"
"math/rand"
"os"
)
var randomSeed seed.Seed
func main() {
InitializeRandomSeed()
AddScene("hud", hudScene)
AddScene("game", gameScene)
SetScene("hud")
// Start game loop.
if err := ebiten.Run(GameLoop, width, height, 1.0, title); err != nil {
log.Fatal("Unable to start game: ", err)
}
}
// GameLoop is the main game loop, updating the current game updateState and (optionally) drawing it.
func GameLoop(screen *ebiten.Image) error {
CheckExitKey()
CheckFullscreenKey()
GetCurrentScene().Update()
if !ebiten.IsDrawingSkipped() {
GetCurrentScene().Draw(screen)
}
return nil
}
func InitializeRandomSeed() {
randomSeed = seed.New()
if len(os.Args) > 1 {
randomSeed = seed.NewPreset(os.Args[1])
}
rand.Seed(randomSeed.Seed)
}