mirror of
https://codeberg.org/scip/golsky.git
synced 2025-12-16 20:20:57 +01:00
45 lines
718 B
Go
45 lines
718 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"runtime/pprof"
|
|
|
|
_ "net/http/pprof"
|
|
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
)
|
|
|
|
func main() {
|
|
config, err := ParseCommandline()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
if config.ShowVersion {
|
|
fmt.Printf("This is golsky version %s\n", VERSION)
|
|
os.Exit(0)
|
|
}
|
|
|
|
game := NewGame(config, Play)
|
|
|
|
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()
|
|
}
|
|
|
|
// main loop
|
|
if err := ebiten.RunGame(game); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|