boxbrawl/flags.go

49 lines
1.4 KiB
Go
Raw Normal View History

//go:build !js || !wasm
// +build !js !wasm
package main
import (
"flag"
"log"
"os"
"code.rocketnine.space/tslocum/boxbrawl/world"
"github.com/assemblaj/ggpo"
"github.com/hajimehoshi/ebiten/v2"
)
func parseFlags() {
var (
fullscreen bool
hostAddress string
connectAddress string
printDebug bool
)
flag.BoolVar(&fullscreen, "fullscreen", false, "run in fullscreen mode")
flag.BoolVar(&world.DisableVsync, "no-vsync", false, "turn off vsync and run at maximum fps")
flag.StringVar(&hostAddress, "host", "", "start hosting a match on specified address:port")
flag.StringVar(&connectAddress, "connect", "", "connect to a match at specified address:port")
flag.IntVar(&world.LocalPort, "local", 0, "set local port (this is not normally required)")
flag.BoolVar(&printDebug, "debug", false, "enable printing debug messages")
2023-01-10 07:10:33 +00:00
flag.IntVar(&world.TPS, "tps", world.DefaultTPS, "set ticks per second (this is not normally required)")
flag.Parse()
if fullscreen {
ebiten.SetFullscreen(true)
}
if printDebug {
ggpo.SetLogger(log.New(os.Stderr, "GGPO ", log.Ldate|log.Ltime|log.Lmsgprefix))
}
if hostAddress != "" {
world.ConnectPromptHost = true
world.ConnectPromptText = hostAddress
world.ConnectPromptConfirmed = true
} else if connectAddress != "" {
world.ConnectPromptText = connectAddress
world.ConnectPromptConfirmed = true
}
}