-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
59 lines (50 loc) · 1.31 KB
/
main.go
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
package main
import (
"flag"
"fmt"
"os"
"game/mapeditor"
"game/server"
)
func main() {
helpFlag := flag.Bool("help", false, "Hepl message")
editorFlag := flag.Bool("editor", false, "Map Editor")
serverFlag := flag.Bool("server", false, "Start game server")
joinFlag := flag.Bool("join", false, "Join a game server")
ip := flag.String("ip", "", "Server IP address")
port := flag.Int("port", 0, "Server port")
password := flag.String("password", "", "Server password")
flag.Parse()
if *helpFlag {
fmt.Println("Help Message:")
fmt.Println("-help -> show help message")
fmt.Println("-editor -> open map editor")
fmt.Println("Hot multiplayer game:")
fmt.Println("-server")
fmt.Println("Join multiplayer game:")
fmt.Println("game.exe -join -ip 127.0.0.1 -port 3000 -password password")
os.Exit(0)
}
if *joinFlag {
if *ip == "" || *port == 0 {
fmt.Println("Error: -ip and -port must be specified for joining a server.")
flag.Usage()
os.Exit(1)
}
// Add logic to connect to the server
fmt.Printf("Joining server at %s:%d with password %s...\n", *ip, *port, *password)
go JoinServer(*ip, *port, *password)
StartGame()
return
}
if *editorFlag {
mapeditor.StartMapEditor()
return
}
if *serverFlag {
server.StartServer()
return
}
fmt.Print("Starting game...\n")
StartGame()
}