Files
golsky/main.go

56 lines
882 B
Go
Raw Normal View History

2024-05-20 20:19:11 +02:00
package main
import (
2024-05-26 12:33:16 +02:00
"fmt"
2024-05-20 20:19:11 +02:00
"log"
2024-05-21 19:01:08 +02:00
"os"
"runtime/pprof"
_ "net/http/pprof"
2024-05-20 20:19:11 +02:00
"github.com/hajimehoshi/ebiten/v2"
2024-05-21 19:01:08 +02:00
)
2024-05-20 20:19:11 +02:00
func main() {
var directstart bool
if len(os.Args) > 1 {
directstart = true
}
config, err := ParseCommandline()
if err != nil {
log.Fatal(err)
}
2024-05-21 19:01:08 +02:00
2024-05-26 12:33:16 +02:00
if config.ShowVersion {
fmt.Printf("This is golsky version %s\n", VERSION)
os.Exit(0)
}
start := Play
if !directstart {
start = Menu
config.DelayedStart = true
}
game := NewGame(config, SceneName(start))
if config.ProfileFile != "" {
// enable cpu profiling. Do NOT use q to stop the game but
// close the window to get a profile
fd, err := os.Create(config.ProfileFile)
if err != nil {
log.Fatal(err)
}
defer fd.Close()
pprof.StartCPUProfile(fd)
defer pprof.StopCPUProfile()
}
2024-05-20 20:19:11 +02:00
// main loop
2024-05-20 20:19:11 +02:00
if err := ebiten.RunGame(game); err != nil {
log.Fatal(err)
}
}