5 Commits

Author SHA1 Message Date
d5bb464d9f Add system messages to chat 2025-01-20 00:03:50 +01:00
4549ee7517 Fix cgo bullshit in build 2025-01-19 23:28:04 +01:00
31ae9c525f mod 2025-01-19 23:22:09 +01:00
06913a5217 Update buildscript and readme 2025-01-19 22:50:50 +01:00
49663c9094 rm build artefacts from git tracking 2025-01-19 22:25:48 +01:00
34 changed files with 71 additions and 879718 deletions

View File

@ -16,24 +16,57 @@ A multiplayer isometric game inspired by Oldschool RuneScape, built with Go and
## Prerequisites
- Go 1.23 or higher
- GCC (for CGO/SQLite support)
- OpenGL development libraries
- Raylib dependencies (see [raylib-go](https://github.com/gen2brain/raylib-go#requirements))
## Installation
1. Clone the repository:
### Pre-built Binaries
The easiest way to get started is to download the latest release from:
```
https://gitea.boner.be/bdnugget/goonscape/releases
```
Choose the appropriate zip file for your platform:
- Windows: `goonscape-windows-amd64-v1.1.0.zip`
- Linux: `goonscape-linux-amd64-v1.1.0.zip`
Extract the zip and run the executable.
### Quick Start
For development:
```bash
# Run directly (recommended for development)
go run main.go
# Run with local server
go run main.go -local
```
### Server Setup
The server requires CGO for SQLite support:
```bash
# Enable CGO
go env -w CGO_ENABLED=1
# Clone and build server
git clone https://gitea.boner.be/bdnugget/goonserver.git
cd goonserver
go build
```
### Client Installation
Then install or build:
```bash
# Install the client
go install gitea.boner.be/bdnugget/goonscape@latest
```
Or build from source:
```bash
git clone https://gitea.boner.be/bdnugget/goonscape.git
cd goonscape
```
2. Install dependencies:
```bash
go mod tidy
```
3. Build and run:
```bash
go run main.go
go build
```
## Controls

Binary file not shown.

View File

@ -1,12 +0,0 @@
# 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.

Before

Width:  |  Height:  |  Size: 2.2 MiB

View File

@ -1,12 +0,0 @@
# 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.

Before

Width:  |  Height:  |  Size: 2.5 MiB

View File

@ -1,12 +0,0 @@
# 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.

Before

Width:  |  Height:  |  Size: 4.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

View File

@ -1,12 +0,0 @@
# 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.

Before

Width:  |  Height:  |  Size: 2.2 MiB

View File

@ -1,12 +0,0 @@
# 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.

Before

Width:  |  Height:  |  Size: 2.5 MiB

View File

@ -1,12 +0,0 @@
# 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.

Before

Width:  |  Height:  |  Size: 4.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

View File

@ -118,8 +118,14 @@ func (c *Chat) Draw(screenWidth, screenHeight int32) {
for i := startIdx; i < endIdx; i++ {
msg := c.messages[i]
var color rl.Color
if msg.PlayerID == 0 { // System message
color = rl.Gold
} else {
color = rl.White
}
text := fmt.Sprintf("%s: %s", msg.Username, msg.Content)
rl.DrawText(text, int32(chatX)+5, int32(messageY), 20, rl.White)
rl.DrawText(text, int32(chatX)+5, int32(messageY), 20, color)
messageY += messageHeight
}

2
go.mod
View File

@ -3,7 +3,7 @@ module gitea.boner.be/bdnugget/goonscape
go 1.23.0
require (
gitea.boner.be/bdnugget/goonserver v0.0.0-20250113131525-49e23114973c
gitea.boner.be/bdnugget/goonserver v1.1.0
github.com/gen2brain/raylib-go/raylib v0.0.0-20250109172833-6dbba4f81a9b
google.golang.org/protobuf v1.36.3
)

View File

@ -100,6 +100,9 @@ func HandleServerCommunication(conn net.Conn, playerID int32, player *types.Play
// Create a channel to signal when goroutines are done
done := make(chan struct{})
// Create a set of current players to track disconnects
currentPlayers := make(map[int32]bool)
go func() {
for {
select {
@ -194,6 +197,7 @@ func HandleServerCommunication(conn net.Conn, playerID int32, player *types.Play
player.Unlock()
for _, state := range serverMessage.Players {
currentPlayers[state.PlayerId] = true
if state.PlayerId == playerID {
player.Lock()
// Update initial position if not set
@ -216,6 +220,13 @@ func HandleServerCommunication(conn net.Conn, playerID int32, player *types.Play
}
}
// Remove players that are no longer in the server state
for id := range otherPlayers {
if !currentPlayers[id] {
delete(otherPlayers, id)
}
}
if handler, ok := player.UserData.(types.ChatMessageHandler); ok && len(serverMessage.ChatMessages) > 0 {
handler.HandleServerMessages(serverMessage.ChatMessages)
}

View File

@ -6,12 +6,15 @@ build() {
local arch=$2
local output=$3
# Set CGO flags for static linking
export CGO_ENABLED=1
# Set GOOS and GOARCH for cross-compilation
export GOOS=$os
export GOARCH=$arch
# Platform specific flags
# Disable CGO only for cross-compilation
if [ "$os" != "$(go env GOOS)" ] || [ "$arch" != "$(go env GOARCH)" ]; then
export CGO_ENABLED=0
fi
if [ "$os" = "windows" ]; then
export CC=x86_64-w64-mingw32-gcc
export CXX=x86_64-w64-mingw32-g++