-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
77 lines (63 loc) · 1.89 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
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
//go:build linux || windows
package main
import (
"flag"
"log"
"os"
"runtime/pprof"
"github.com/hajimehoshi/ebiten/v2"
"oddstream.games/gosold/dark"
light "oddstream.games/gosold/light"
)
func main() {
var DebugMode bool
log.SetFlags(0)
// pearl from the mudbank: don't have any flags that will overwrite ThePreferences
flag.BoolVar(&DebugMode, "debug", false, "turn debug mode on")
flag.BoolVar(&light.DrawBoxes, "boxes", false, "draw boundary boxes (in -debug mode)")
flag.BoolVar(&dark.NoLoad, "noload", false, "do not load saved game when starting")
flag.BoolVar(&dark.NoSave, "nosave", false, "do not save game before exit")
var cpuProfile = flag.String("cpuprofile", "", "write cpu profile to file")
flag.Parse()
if DebugMode {
dark.DebugMode = true
light.DebugMode = true
for i, a := range os.Args {
log.Println(i, a)
}
}
if *cpuProfile != "" {
var f *os.File
var err error
if f, err = os.Create(*cpuProfile); err != nil {
log.Fatal(err)
}
if err = pprof.StartCPUProfile(f); err != nil {
log.Fatal(err)
}
defer pprof.StopCPUProfile()
}
ebiten.SetScreenClearedEveryFrame(false)
// ebiten panics if a window to maximize is not resizable
ebiten.SetWindowResizingMode(ebiten.WindowResizingModeEnabled)
if ebiten.IsWindowMaximized() || ebiten.IsWindowMinimized() {
// GNOME (maybe) annoyingly keeps maximizing the window
ebiten.RestoreWindow()
}
{
n := max(ebiten.ScreenSizeInFullscreen())
ebiten.SetWindowSize(n/2, n/2)
}
ebiten.SetWindowIcon(light.WindowIcons())
ebiten.SetWindowTitle("Go Solitaire")
g := light.NewGame()
if err := ebiten.RunGame(g); err != nil {
log.Fatal(err)
}
// we come here if the user closed the window with the x button
// but we don't come here if ExitRequested has been set
// (and Game.Update() returned an error)
// which another thing I don't understand
// log.Println("main exit")Game.Exit
g.ExitGame()
}