-
Notifications
You must be signed in to change notification settings - Fork 0
/
play.go
52 lines (42 loc) · 1.07 KB
/
play.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
package cmd
import (
"log"
"net/http"
"runtime"
"github.com/hajimehoshi/ebiten/v2"
"github.com/kijimaD/ruins/lib/game"
"github.com/pkg/profile"
"github.com/urfave/cli/v2"
_ "net/http/pprof"
es "github.com/kijimaD/ruins/lib/engine/states"
gs "github.com/kijimaD/ruins/lib/states"
)
var CmdPlay = &cli.Command{
Name: "play",
Usage: "play",
Description: "play game",
Action: runPlay,
Flags: []cli.Flag{},
}
const (
minGameWidth = 960
minGameHeight = 720
)
func runPlay(_ *cli.Context) error {
ebiten.SetWindowResizingMode(ebiten.WindowResizingModeEnabled)
ebiten.SetWindowSize(minGameWidth, minGameHeight)
ebiten.SetWindowTitle("ruins")
// プロファイラ。WASMは除外する
if runtime.GOOS != "js" {
defer profile.Start(profile.MemProfile, profile.ProfilePath(".")).Stop()
go func() {
log.Fatal(http.ListenAndServe("localhost:6060", nil))
}()
}
world := game.InitWorld(minGameWidth, minGameHeight)
ebiten.RunGame(&game.MainGame{
World: world,
StateMachine: es.Init(&gs.MainMenuState{}, world),
})
return nil
}