arcticwarfare/flags.go
2024-02-08 16:55:21 -08:00

33 lines
651 B
Go

//go:build !js || !wasm
package main
import (
"flag"
"fmt"
"log"
"net/http"
_ "net/http/pprof"
"code.rocket9labs.com/tslocum/arcticwarfare/game"
)
func parseFlags() *game.Game {
var allTanks bool
var godMode bool
var debugPort int
flag.BoolVar(&allTanks, "all-tanks", false, "Enable all tanks")
flag.BoolVar(&godMode, "god", false, "God mode")
flag.IntVar(&debugPort, "debug", 0, "Port to serve pprof debug information on")
flag.Parse()
debug := 0
if debugPort > 0 {
debug = 1
go func() {
log.Fatal(http.ListenAndServe(fmt.Sprintf("localhost:%d", debugPort), nil))
}()
}
return game.NewGame(allTanks, godMode, debug)
}