-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
58 lines (46 loc) · 1004 Bytes
/
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
package main
import (
"errors"
_ "image/png"
"log"
"os"
"path"
"path/filepath"
"runtime"
"github.com/hajimehoshi/ebiten/v2"
)
// Version holds the compile-time version string of Ivan.
// nolint:gochecknoglobals
var Version = "unknown"
func main() {
log.Printf("ivan %s\n", Version)
chdirToExecutableDir()
ebiten.SetWindowTitle("Ivan")
ebiten.SetRunnableOnUnfocused(true)
ebiten.SetWindowResizable(true)
// Undecorated windows can't be moved under Windows or Darwin.
if runtime.GOOS == "linux" {
ebiten.SetWindowDecorated(false)
}
ivan, err := NewApp()
if err != nil {
log.Fatal(err)
}
if err := ebiten.RunGame(ivan); err != nil && !errors.Is(err, errCloseApp) {
log.Fatal(err)
}
}
func chdirToExecutableDir() {
exec, err := os.Executable()
if err != nil {
log.Fatal(err)
}
solved, err := filepath.EvalSymlinks(exec)
if err != nil {
log.Printf("warning: %s", err)
solved = exec
}
if err := os.Chdir(path.Dir(solved)); err != nil {
log.Fatal(err)
}
}