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"
|
2024-05-27 13:38:14 +02:00
|
|
|
"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() {
|
2024-06-01 20:22:28 +02:00
|
|
|
var directstart bool
|
2024-05-30 19:45:13 +02:00
|
|
|
|
|
|
|
|
if len(os.Args) > 1 {
|
2024-06-01 20:22:28 +02:00
|
|
|
directstart = true
|
2024-05-30 19:45:13 +02:00
|
|
|
}
|
2024-06-01 20:22:28 +02:00
|
|
|
|
2024-05-27 13:38:14 +02:00
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-30 19:45:13 +02:00
|
|
|
start := Play
|
2024-06-01 20:22:28 +02:00
|
|
|
if !directstart {
|
2024-05-30 19:45:13 +02:00
|
|
|
start = Menu
|
2024-06-01 20:22:28 +02:00
|
|
|
config.DelayedStart = true
|
2024-05-30 19:45:13 +02:00
|
|
|
}
|
|
|
|
|
game := NewGame(config, SceneName(start))
|
2024-05-26 20:26:13 +02:00
|
|
|
|
2024-05-27 13:38:14 +02:00
|
|
|
if config.ProfileFile != "" {
|
2024-05-28 00:07:31 +02:00
|
|
|
// enable cpu profiling. Do NOT use q to stop the game but
|
|
|
|
|
// close the window to get a profile
|
2024-05-27 13:38:14 +02:00
|
|
|
fd, err := os.Create(config.ProfileFile)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
defer fd.Close()
|
2024-05-26 20:26:13 +02:00
|
|
|
|
2024-05-27 13:38:14 +02:00
|
|
|
pprof.StartCPUProfile(fd)
|
|
|
|
|
defer pprof.StopCPUProfile()
|
|
|
|
|
}
|
2024-05-20 20:19:11 +02:00
|
|
|
|
2024-05-23 14:27:42 +02:00
|
|
|
// main loop
|
2024-05-20 20:19:11 +02:00
|
|
|
if err := ebiten.RunGame(game); err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
}
|