1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
package main
import (
"flag"
"io"
"log"
"os"
"github.com/hajimehoshi/ebiten/v2"
"muhq.space/muhqs-game/go/activities"
"muhq.space/muhqs-game/go/font"
)
const (
WINDOW_WIDTH = 800
WINDOW_HEIGHT = 1024
)
var startDeckPath string
type app struct {
windowWidth int
windowHeight int
}
func (a *app) Update() error {
return activities.CurActivity().Update()
}
func (a *app) Draw(screen *ebiten.Image) {
activities.CurActivity().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`
}
activities.PushActivity(startMenu)
if err := ebiten.RunGame(app); err != nil {
if err != ebiten.Termination {
log.Fatal(err)
}
}
}
|