6 Commits

35 changed files with 879827 additions and 11 deletions

30
Dockerfile.build Normal file
View File

@ -0,0 +1,30 @@
FROM golang:1.23
# Install build dependencies
RUN apt-get update && apt-get install -y \
gcc-mingw-w64 \
cmake \
zip \
libasound2-dev \
mesa-common-dev \
libx11-dev \
libxrandr-dev \
libxi-dev \
xorg-dev \
libgl1-mesa-dev \
libglu1-mesa-dev \
libwayland-dev \
wayland-protocols \
libxkbcommon-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
# Copy build scripts
COPY . /build/
# Set execute permissions
RUN chmod +x /build/scripts/build.sh
# Build command
CMD ["make", "all"]

30
Makefile Normal file
View File

@ -0,0 +1,30 @@
.PHONY: all clean windows linux darwin
include scripts/platforms.mk
BINARY_NAME=goonscape
VERSION=1.0.0
BUILD_DIR=build
ASSETS_DIR=resources
all: clean $(PLATFORMS)
$(PLATFORMS):
@echo "Building for $@..."
@mkdir -p $(BUILD_DIR)/$@
@scripts/build.sh $(word 1,$(subst /, ,$@)) $(word 2,$(subst /, ,$@)) \
$(BUILD_DIR)/$@/$(BINARY_NAME)$(if $(findstring windows,$@),.exe,)
@cp -r $(ASSETS_DIR) $(BUILD_DIR)/$@/
@cd $(BUILD_DIR) && zip -r $(BINARY_NAME)-$(word 1,$(subst /, ,$@))-$(word 2,$(subst /, ,$@))-v$(VERSION).zip $@
@echo "Done building for $@"
clean:
rm -rf $(BUILD_DIR)
# Development build for current platform
dev:
go build -o $(BINARY_NAME)
# Run tests
test:
go test ./...

View File

@ -63,6 +63,26 @@ go run main.go -addr somehost:6970 # Uses somehost:6970
Note: The `-local` flag is a shorthand for `-addr localhost:6969` and cannot be used together with `-addr`.
## Building Release Binaries
The project uses Docker to create consistent builds across platforms. To build release binaries:
1. Build the Docker image (only needed once):
```bash
sudo docker build -t goonscape-builder -f Dockerfile.build .
```
2. Create release builds:
```bash
sudo docker run -v $(pwd):/build goonscape-builder
```
This will create zip files in the `build` directory for:
- Windows (64-bit): `goonscape-windows-amd64-v1.0.0.zip`
- Linux (64-bit): `goonscape-linux-amd64-v1.0.0.zip`
Each zip contains the binary and all required assets.
## Development
The project uses Protocol Buffers for network communication. If you modify the `.proto` files, regenerate the Go code with:

Binary file not shown.

Binary file not shown.

BIN
build/linux/amd64/goonscape Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,12 @@
# Blender 3.6.0 MTL File: 'None'
# www.blender.org
newmtl Material.001
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd coomer.png

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

View File

@ -0,0 +1,12 @@
# Blender 3.6.0 MTL File: 'None'
# www.blender.org
newmtl Material.001
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd goonion.png

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

View File

@ -0,0 +1,12 @@
# Blender 3.6.0 MTL File: 'None'
# www.blender.org
newmtl Material.001
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd shreke.png

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

BIN
build/windows/amd64/goonscape.exe Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,12 @@
# Blender 3.6.0 MTL File: 'None'
# www.blender.org
newmtl Material.001
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd coomer.png

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

View File

@ -0,0 +1,12 @@
# Blender 3.6.0 MTL File: 'None'
# www.blender.org
newmtl Material.001
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd goonion.png

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

View File

@ -0,0 +1,12 @@
# Blender 3.6.0 MTL File: 'None'
# www.blender.org
newmtl Material.001
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd shreke.png

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

View File

@ -1,6 +1,7 @@
package game
import (
"os"
"time"
"gitea.boner.be/bdnugget/goonscape/assets"
@ -18,7 +19,6 @@ type Game struct {
Chat *Chat
MenuOpen bool
QuitChan chan struct{} // Channel to signal shutdown
QuitDone chan struct{} // New channel to signal when cleanup is complete
}
func New() *Game {
@ -42,7 +42,6 @@ func New() *Game {
},
Chat: NewChat(),
QuitChan: make(chan struct{}),
QuitDone: make(chan struct{}),
}
game.Player.UserData = game
game.Chat.userData = game
@ -142,7 +141,7 @@ func (g *Game) DrawPlayer(player *types.Player, model rl.Model) {
rl.DrawModel(model, playerPos, 16, rl.White)
if player.FloatingMessage != nil && time.Now().Before(player.FloatingMessage.ExpireTime) {
if player.FloatingMessage != nil {
screenPos := rl.GetWorldToScreen(rl.Vector3{
X: playerPos.X,
Y: playerPos.Y + 24.0,
@ -150,8 +149,6 @@ func (g *Game) DrawPlayer(player *types.Player, model rl.Model) {
}, g.Camera)
player.FloatingMessage.ScreenPos = screenPos
} else if player.FloatingMessage != nil {
player.FloatingMessage = nil
}
if len(player.TargetPath) > 0 {
@ -293,9 +290,7 @@ func (g *Game) DrawMenu() {
case "Settings":
// TODO: Implement settings
case "Exit Game":
close(g.QuitChan)
<-g.QuitDone
rl.CloseWindow()
g.Shutdown()
}
}
}
@ -310,3 +305,10 @@ func (g *Game) DrawMenu() {
buttonY += buttonSpacing
}
}
func (g *Game) Shutdown() {
close(g.QuitChan)
<-g.Player.QuitDone
rl.CloseWindow()
os.Exit(0)
}

View File

@ -111,9 +111,18 @@ func HandleServerCommunication(conn net.Conn, playerID int32, player *types.Play
for {
select {
case <-quitChan:
<-done // Wait for action goroutine to finish
close(done)
time.Sleep(100 * time.Millisecond) // Give time for disconnect message to be sent
done := make(chan struct{})
go func() {
<-done
close(player.QuitDone)
}()
select {
case <-done:
time.Sleep(100 * time.Millisecond)
case <-time.After(1 * time.Second):
log.Println("Shutdown timed out")
}
return
default:
// Read message length (4 bytes)

24
scripts/build.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
# Main build process
build() {
local os=$1
local arch=$2
local output=$3
# Set CGO flags for static linking
export CGO_ENABLED=1
export GOOS=$os
export GOARCH=$arch
# Platform specific flags
if [ "$os" = "windows" ]; then
export CC=x86_64-w64-mingw32-gcc
export CXX=x86_64-w64-mingw32-g++
fi
go build -buildvcs=false -ldflags="-s -w" -o $output
}
# Call build with provided arguments
build "$1" "$2" "$3"

1
scripts/platforms.mk Normal file
View File

@ -0,0 +1 @@
PLATFORMS=windows/amd64 linux/amd64