diff options
Diffstat (limited to 'go/client/main.go')
| -rw-r--r-- | go/client/main.go | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/go/client/main.go b/go/client/main.go new file mode 100644 index 00000000..3635404f --- /dev/null +++ b/go/client/main.go @@ -0,0 +1,95 @@ +package main + +import ( + "flag" + "image/color" + "io" + "log" + "os" + + "github.com/hajimehoshi/ebiten/v2" + + "muhq.space/muhqs-game/go/font" +) + +const ( + WINDOW_WIDTH = 800 + WINDOW_HEIGHT = 1024 +) + +var playerColors = []color.RGBA{ + {1, 0xff, 1, 0xff}, + {1, 1, 0xff, 0xff}, +} + +var ( + playerName string + startDeckPath string +) + +type app struct { + windowWidth int + windowHeight int + + active ebiten.Game + running bool +} + +func (a *app) Update() error { + return a.active.Update() +} + +func (a *app) Draw(screen *ebiten.Image) { + a.active.Draw(screen) +} + +func (a *app) Layout(outsideWidth, outsideHeight int) (int, int) { + return a.windowWidth, a.windowHeight +} + +func main() { + font.InitFont() + + app := &app{} + startMenu := NewStartMenu(app) + + flag.IntVar(&app.windowWidth, "windowWidth", WINDOW_WIDTH, "the window width") + flag.IntVar(&app.windowHeight, "windowHeight", WINDOW_HEIGHT, "the window height") + + flag.StringVar(&startMenu.playerName, "player", "muhq", "player name") + flag.StringVar(&startDeckPath, "deck", "", "deck list to load") + + flag.StringVar(&startMenu.mapPath, "map", "the-kraken", "the map to load") + flag.StringVar(&startMenu.remote, "remote", "", "address of remote game to connect to") + flag.Parse() + + ebiten.SetWindowSize(app.windowWidth, app.windowHeight) + ebiten.SetWindowTitle("Muhq's Game") + + startMenu.width, startMenu.height = app.windowWidth, app.windowHeight + + if startDeckPath != "" { + file, err := os.Open(startDeckPath) + if err != nil { + log.Fatal(err) + } + + defer file.Close() + + deckList, err := io.ReadAll(file) + if err != nil { + log.Fatal(err) + } + startMenu.startDeck = string(deckList) + } else { + startMenu.startDeck = `1 nautics/barge +1 nautics/captain +1 nautics/fisher +1 nautics/galley` + } + + app.active = startMenu + if err := ebiten.RunGame(app); err != nil { + log.Fatal(err) + } +} |
