Update networking
parent
aba1cb30f5
commit
e2d71b80f1
|
@ -0,0 +1 @@
|
|||
dist
|
21
game/game.go
21
game/game.go
|
@ -115,37 +115,30 @@ func (g *Game) startNetworkGame() {
|
|||
log.Fatalf("failed to read port: %s", err)
|
||||
}
|
||||
|
||||
localPort := world.LocalPort
|
||||
if localPort == 0 {
|
||||
localPort = p + 1
|
||||
}
|
||||
localPort := p
|
||||
if world.LocalPort != 0 {
|
||||
log.Printf("Client port for connection: %d", world.LocalPort)
|
||||
localPort = world.LocalPort
|
||||
}
|
||||
log.Printf("Client port for connection: %d", localPort)
|
||||
|
||||
numPlayers := 2
|
||||
playerSize := 20
|
||||
|
||||
players := make([]ggpo.Player, numPlayers)
|
||||
if world.ConnectPromptHost {
|
||||
log.Printf("Hosting at " + address + ":" + port + "...")
|
||||
log.Printf("Connecting to " + address + ":" + port + " as host...")
|
||||
|
||||
players[0] = ggpo.NewLocalPlayer(playerSize, 1)
|
||||
players[1] = ggpo.NewRemotePlayer(playerSize, 2, "127.0.0.1", localPort)
|
||||
players[1] = ggpo.NewRemotePlayer(playerSize, 2, address, p)
|
||||
} else {
|
||||
log.Printf("Connecting to " + address + ":" + port + "...")
|
||||
log.Printf("Connecting to " + address + ":" + port + " as guest...")
|
||||
|
||||
world.CurrentPlayer = 2
|
||||
players[0] = ggpo.NewRemotePlayer(playerSize, 1, address, p)
|
||||
players[1] = ggpo.NewLocalPlayer(playerSize, 2)
|
||||
}
|
||||
|
||||
l := p
|
||||
if !world.ConnectPromptHost {
|
||||
l = localPort
|
||||
}
|
||||
|
||||
g.InitNetworking(l, numPlayers, players, 0)
|
||||
g.InitNetworking(localPort, numPlayers, players, 0)
|
||||
|
||||
world.ConnectionActive = true
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
project_name: boxbrawl
|
||||
|
||||
builds:
|
||||
-
|
||||
id: boxbrawl
|
||||
goos:
|
||||
- js
|
||||
- linux
|
||||
- windows
|
||||
goarch:
|
||||
- amd64
|
||||
- wasm
|
||||
archives:
|
||||
-
|
||||
id: boxbrawl
|
||||
builds:
|
||||
- boxbrawl
|
||||
replacements:
|
||||
386: i386
|
||||
format_overrides:
|
||||
- goos: js
|
||||
format: zip
|
||||
- goos: windows
|
||||
format: zip
|
||||
files:
|
||||
- ./*.md
|
||||
- LICENSE
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
|
@ -21,14 +21,14 @@ const uiStartPrompt = `Box Brawl
|
|||
`
|
||||
const uiComputerPrompt = `Press <Enter> to play against the computer.`
|
||||
const uiHostPrompt = `Press <H> to host a match against a remote player.`
|
||||
const uiHostInfoPrompt = `Type a port to host a match against a remote player.`
|
||||
const uiHostInfoPrompt = `Type your opponent's IP address and port (address:port) to host a match.`
|
||||
const uiHostStartPrompt = `Press <Enter> to start hosting.`
|
||||
const uiRemotePrompt = `Type an IP address and port (address:port) to play against a remote player.`
|
||||
const uiRemotePrompt = `Type your opponent's IP address and port (address:port) to join a match.`
|
||||
const uiConnectPrompt = `Press <Enter> to connect.`
|
||||
const uiBrowserPrompt = `Playing against remote players is unavailable in the browser version.
|
||||
|
||||
Download Box Brawl for Windows or Linux to play against remote players.`
|
||||
const uiHostListeningPrompt = `Waiting for a connection on %s...`
|
||||
const uiHostListeningPrompt = `Waiting for opponent to connect from %s...`
|
||||
const uiClientConnectingPrompt = `Connecting to %s...`
|
||||
|
||||
type UISystem struct {
|
||||
|
|
Loading…
Reference in New Issue