Compare commits
17 Commits
feature/db
...
7be859d58f
Author | SHA1 | Date | |
---|---|---|---|
7be859d58f | |||
fde07e3e48 | |||
f966d538d3 | |||
220a451475 | |||
417bf4ea63 | |||
84d63ba4c1 | |||
49b84c8540 | |||
0e509ad752 | |||
bcd63efd7b | |||
944c33ce3b | |||
d5bb464d9f | |||
4549ee7517 | |||
31ae9c525f | |||
06913a5217 | |||
49663c9094 | |||
a843680b09 | |||
7183df4a8b |
15
.gitignore
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# Build artifacts
|
||||
build/
|
||||
goonscape
|
||||
goonscape.exe
|
||||
|
||||
# IDE files
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
|
||||
# OS files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
resources/models/old_and_test/
|
25
.woodpecker.yml
Normal file
@ -0,0 +1,25 @@
|
||||
pipeline:
|
||||
build:
|
||||
image: golang:1.23
|
||||
commands:
|
||||
# Install build dependencies
|
||||
- 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
|
||||
|
||||
# Build for all platforms
|
||||
- make all
|
||||
|
||||
when:
|
||||
event: tag
|
||||
tag: v*
|
||||
|
||||
# Optional: Create Gitea release with built artifacts
|
||||
release:
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: gitea_token
|
||||
base_url: https://gitea.boner.be
|
||||
files: build/*.zip
|
||||
when:
|
||||
event: tag
|
||||
tag: v*
|
24
LICENSE
@ -1,11 +1,21 @@
|
||||
“Commons Clause” License Condition v1.0
|
||||
MIT License
|
||||
|
||||
The Software is provided to you by the Licensor under the License, as defined below, subject to the following condition.
|
||||
Copyright (c) 2025 bdnugget
|
||||
|
||||
Without limiting other conditions in the License, the grant of rights under the License will not include, and the License does not grant to you, right to Sell the Software.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
For purposes of the foregoing, “Sell” means practicing any or all of the rights granted to you under the License to provide to third parties, for a fee or other consideration (including without limitation fees for hosting or consulting/ support services related to the Software), a product or service whose value derives, entirely or substantially, from the functionality of the Software. Any license notice or attribution required by the License must also include this Commons Cause License Condition notice.
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
Software: GoonScape
|
||||
License: Commons Clause v1.0
|
||||
Licensor: bdnugget
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
2
Makefile
@ -3,7 +3,7 @@
|
||||
include scripts/platforms.mk
|
||||
|
||||
BINARY_NAME=goonscape
|
||||
VERSION=1.0.0
|
||||
VERSION=1.1.0
|
||||
BUILD_DIR=build
|
||||
ASSETS_DIR=resources
|
||||
|
||||
|
55
README.md
@ -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
|
||||
|
@ -5,22 +5,79 @@ import (
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
// Helper function to load animations for a model
|
||||
func loadModelAnimations(animPaths map[string]string) (types.AnimationSet, error) {
|
||||
var animSet types.AnimationSet
|
||||
|
||||
// Load idle animations if specified
|
||||
if idlePath, ok := animPaths["idle"]; ok {
|
||||
idleAnims := rl.LoadModelAnimations(idlePath)
|
||||
if len(idleAnims) > 0 {
|
||||
animSet.Idle = idleAnims
|
||||
rl.TraceLog(rl.LogInfo, "Loaded idle animation: %s (%d frames, %f seconds)",
|
||||
idlePath, idleAnims[0].FrameCount, float32(idleAnims[0].FrameCount)/60.0)
|
||||
}
|
||||
}
|
||||
|
||||
// Load walk animations if specified
|
||||
if walkPath, ok := animPaths["walk"]; ok {
|
||||
walkAnims := rl.LoadModelAnimations(walkPath)
|
||||
if len(walkAnims) > 0 {
|
||||
animSet.Walk = walkAnims
|
||||
rl.TraceLog(rl.LogInfo, "Loaded walk animation: %s (%d frames, %f seconds)",
|
||||
walkPath, walkAnims[0].FrameCount, float32(walkAnims[0].FrameCount)/60.0)
|
||||
}
|
||||
}
|
||||
|
||||
return animSet, nil
|
||||
}
|
||||
|
||||
func LoadModels() ([]types.ModelAsset, error) {
|
||||
goonerModel := rl.LoadModel("resources/models/goonion.obj")
|
||||
goonerTexture := rl.LoadTexture("resources/models/goonion.png")
|
||||
rl.SetMaterialTexture(goonerModel.Materials, rl.MapDiffuse, goonerTexture)
|
||||
// Goonion model and animations
|
||||
goonerModel := rl.LoadModel("resources/models/gooner/walk_no_y_transform.glb")
|
||||
goonerAnims, _ := loadModelAnimations(map[string]string{"idle": "resources/models/gooner/idle_no_y_transform.glb", "walk": "resources/models/gooner/walk_no_y_transform.glb"})
|
||||
|
||||
coomerModel := rl.LoadModel("resources/models/coomer.obj")
|
||||
coomerTexture := rl.LoadTexture("resources/models/coomer.png")
|
||||
rl.SetMaterialTexture(coomerModel.Materials, rl.MapDiffuse, coomerTexture)
|
||||
// Apply transformations
|
||||
transform := rl.MatrixIdentity()
|
||||
transform = rl.MatrixMultiply(transform, rl.MatrixRotateY(180*rl.Deg2rad))
|
||||
transform = rl.MatrixMultiply(transform, rl.MatrixRotateX(-90*rl.Deg2rad))
|
||||
transform = rl.MatrixMultiply(transform, rl.MatrixScale(1.0, 1.0, 1.0))
|
||||
goonerModel.Transform = transform
|
||||
|
||||
// Coomer model (ready for animations)
|
||||
coomerModel := rl.LoadModel("resources/models/coomer/idle_notransy.glb")
|
||||
// coomerTexture := rl.LoadTexture("resources/models/coomer.png")
|
||||
// rl.SetMaterialTexture(coomerModel.Materials, rl.MapDiffuse, coomerTexture)
|
||||
// When you have animations, add them like:
|
||||
coomerAnims, _ := loadModelAnimations(map[string]string{"idle": "resources/models/coomer/idle_notransy.glb", "walk": "resources/models/coomer/unsteadywalk_notransy.glb"})
|
||||
coomerModel.Transform = transform
|
||||
|
||||
// Shreke model (ready for animations)
|
||||
shrekeModel := rl.LoadModel("resources/models/shreke.obj")
|
||||
shrekeTexture := rl.LoadTexture("resources/models/shreke.png")
|
||||
rl.SetMaterialTexture(shrekeModel.Materials, rl.MapDiffuse, shrekeTexture)
|
||||
// When you have animations, add them like:
|
||||
// shrekeAnims, _ := loadModelAnimations("resources/models/shreke.glb",
|
||||
// map[string]string{
|
||||
// "idle": "resources/models/shreke_idle.glb",
|
||||
// "walk": "resources/models/shreke_walk.glb",
|
||||
// })
|
||||
|
||||
return []types.ModelAsset{
|
||||
{Model: goonerModel, Texture: goonerTexture},
|
||||
{Model: coomerModel, Texture: coomerTexture},
|
||||
{
|
||||
Model: goonerModel,
|
||||
Animation: append(goonerAnims.Idle, goonerAnims.Walk...),
|
||||
AnimFrames: int32(len(goonerAnims.Idle) + len(goonerAnims.Walk)),
|
||||
Animations: goonerAnims,
|
||||
YOffset: 0.0,
|
||||
},
|
||||
{
|
||||
Model: coomerModel,
|
||||
Animation: append(coomerAnims.Idle, coomerAnims.Walk...),
|
||||
AnimFrames: int32(len(coomerAnims.Idle) + len(coomerAnims.Walk)),
|
||||
Animations: coomerAnims,
|
||||
YOffset: -4.0,
|
||||
},
|
||||
{Model: shrekeModel, Texture: shrekeTexture},
|
||||
}, nil
|
||||
}
|
||||
@ -31,6 +88,11 @@ func LoadMusic(filename string) (rl.Music, error) {
|
||||
|
||||
func UnloadModels(models []types.ModelAsset) {
|
||||
for _, model := range models {
|
||||
if model.Animation != nil {
|
||||
for i := int32(0); i < model.AnimFrames; i++ {
|
||||
rl.UnloadModelAnimation(model.Animation[i])
|
||||
}
|
||||
}
|
||||
rl.UnloadModel(model.Model)
|
||||
rl.UnloadTexture(model.Texture)
|
||||
}
|
||||
|
@ -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
|
Before Width: | Height: | Size: 2.2 MiB |
@ -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
|
Before Width: | Height: | Size: 2.5 MiB |
@ -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
|
Before Width: | Height: | Size: 4.8 MiB |
Before Width: | Height: | Size: 104 KiB |
@ -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
|
Before Width: | Height: | Size: 2.2 MiB |
@ -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
|
Before Width: | Height: | Size: 2.5 MiB |
@ -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
|
Before Width: | Height: | Size: 4.8 MiB |
Before Width: | Height: | Size: 104 KiB |
@ -10,6 +10,7 @@ var (
|
||||
cameraDistance = float32(20.0)
|
||||
cameraYaw = float32(145.0)
|
||||
cameraPitch = float32(45.0)
|
||||
lastMousePos rl.Vector2 // Add this to track mouse movement
|
||||
)
|
||||
|
||||
func UpdateCamera(camera *rl.Camera3D, player rl.Vector3, deltaTime float32) {
|
||||
@ -32,6 +33,34 @@ func UpdateCamera(camera *rl.Camera3D, player rl.Vector3, deltaTime float32) {
|
||||
}
|
||||
}
|
||||
|
||||
// Handle middle mouse camera rotation
|
||||
if rl.IsMouseButtonDown(rl.MouseMiddleButton) {
|
||||
currentMousePos := rl.GetMousePosition()
|
||||
|
||||
// If we just started holding the button, initialize last position
|
||||
if !rl.IsMouseButtonPressed(rl.MouseMiddleButton) {
|
||||
mouseDelta := rl.Vector2{
|
||||
X: currentMousePos.X - lastMousePos.X,
|
||||
Y: currentMousePos.Y - lastMousePos.Y,
|
||||
}
|
||||
|
||||
// Adjust rotation speed as needed
|
||||
cameraYaw += mouseDelta.X * 0.5 * deltaTime * 60
|
||||
cameraPitch += mouseDelta.Y * 0.5 * deltaTime * 60
|
||||
|
||||
// Clamp pitch to prevent camera flipping
|
||||
if cameraPitch < 20 {
|
||||
cameraPitch = 20
|
||||
}
|
||||
if cameraPitch > 85 {
|
||||
cameraPitch = 85
|
||||
}
|
||||
}
|
||||
|
||||
lastMousePos = currentMousePos
|
||||
}
|
||||
|
||||
// Keep the keyboard controls too
|
||||
if rl.IsKeyDown(rl.KeyRight) {
|
||||
cameraYaw += 100 * deltaTime
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
41
game/game.go
@ -68,17 +68,14 @@ func (g *Game) Update(deltaTime float32) {
|
||||
return
|
||||
}
|
||||
|
||||
// Assign model based on player ID
|
||||
modelIndex := int(playerID) % len(g.Models)
|
||||
g.Player = &types.Player{
|
||||
Speed: 50.0,
|
||||
TargetPath: []types.Tile{},
|
||||
UserData: g,
|
||||
QuitDone: make(chan struct{}),
|
||||
ID: playerID,
|
||||
Model: g.Models[modelIndex].Model,
|
||||
Texture: g.Models[modelIndex].Texture,
|
||||
}
|
||||
g.AssignModelToPlayer(g.Player)
|
||||
|
||||
go network.HandleServerCommunication(conn, playerID, g.Player, g.OtherPlayers, g.QuitChan)
|
||||
g.isLoggedIn = true
|
||||
@ -157,14 +154,32 @@ func (g *Game) DrawPlayer(player *types.Player, model rl.Model) {
|
||||
defer player.Unlock()
|
||||
|
||||
grid := GetMapGrid()
|
||||
modelIndex := int(player.ID) % len(g.Models)
|
||||
modelAsset := g.Models[modelIndex]
|
||||
|
||||
const defaultHeight = 8.0 // Default height above tile, fine tune per model in types.ModelAsset
|
||||
playerPos := rl.Vector3{
|
||||
X: player.PosActual.X,
|
||||
Y: grid[player.PosTile.X][player.PosTile.Y].Height*types.TileHeight + 16.0,
|
||||
Y: grid[player.PosTile.X][player.PosTile.Y].Height*types.TileHeight + defaultHeight + modelAsset.YOffset,
|
||||
Z: player.PosActual.Z,
|
||||
}
|
||||
|
||||
// Check if model has animations
|
||||
if modelAsset.Animations.Idle != nil || modelAsset.Animations.Walk != nil {
|
||||
if player.IsMoving && len(modelAsset.Animations.Walk) > 0 {
|
||||
anim := modelAsset.Animations.Walk[0] // Use first walk animation
|
||||
player.AnimationFrame = player.AnimationFrame % anim.FrameCount
|
||||
rl.UpdateModelAnimation(model, anim, player.AnimationFrame)
|
||||
} else if len(modelAsset.Animations.Idle) > 0 {
|
||||
anim := modelAsset.Animations.Idle[0] // Use first idle animation
|
||||
player.AnimationFrame = player.AnimationFrame % anim.FrameCount
|
||||
rl.UpdateModelAnimation(model, anim, player.AnimationFrame)
|
||||
}
|
||||
}
|
||||
|
||||
rl.DrawModel(model, playerPos, 16, rl.White)
|
||||
|
||||
// Draw floating messages and path indicators
|
||||
if player.FloatingMessage != nil {
|
||||
screenPos := rl.GetWorldToScreen(rl.Vector3{
|
||||
X: playerPos.X,
|
||||
@ -207,12 +222,9 @@ func (g *Game) Render() {
|
||||
rl.BeginMode3D(g.Camera)
|
||||
g.DrawMap()
|
||||
g.DrawPlayer(g.Player, g.Player.Model)
|
||||
for id, other := range g.OtherPlayers {
|
||||
for _, other := range g.OtherPlayers {
|
||||
if other.Model.Meshes == nil {
|
||||
// Assign model based on player ID for consistency
|
||||
modelIndex := int(id) % len(g.Models)
|
||||
other.Model = g.Models[modelIndex].Model
|
||||
other.Texture = g.Models[modelIndex].Texture
|
||||
g.AssignModelToPlayer(other)
|
||||
}
|
||||
g.DrawPlayer(other, other.Model)
|
||||
}
|
||||
@ -352,3 +364,12 @@ func (g *Game) Shutdown() {
|
||||
func (g *Game) HandleServerMessages(messages []*pb.ChatMessage) {
|
||||
g.Chat.HandleServerMessages(messages)
|
||||
}
|
||||
|
||||
func (g *Game) AssignModelToPlayer(player *types.Player) {
|
||||
modelIndex := int(player.ID) % len(g.Models)
|
||||
modelAsset := g.Models[modelIndex]
|
||||
|
||||
// Just use the original model - don't try to copy it
|
||||
player.Model = modelAsset.Model
|
||||
player.Texture = modelAsset.Texture
|
||||
}
|
||||
|
2
go.mod
@ -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
|
||||
)
|
||||
|
@ -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)
|
||||
}
|
||||
|
BIN
resources/models/coomer/Animation_Confused_Scratch_withSkin.glb
Normal file
BIN
resources/models/coomer/Animation_Idle_withSkin.glb
Normal file
BIN
resources/models/coomer/Animation_Running_withSkin.glb
Normal file
BIN
resources/models/coomer/Animation_Unsteady_Walk_withSkin.glb
Normal file
BIN
resources/models/coomer/Animation_Walking_withSkin.glb
Normal file
BIN
resources/models/coomer/idle_notransy.glb
Normal file
BIN
resources/models/coomer/unsteadywalk_notransy.glb
Normal file
BIN
resources/models/coomerAnim.zip
Normal file
BIN
resources/models/gooner/idle_no_y_transform.glb
Normal file
BIN
resources/models/gooner/walk_no_y_transform.glb
Normal 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++
|
||||
|
@ -19,6 +19,33 @@ func (p *Player) MoveTowards(target Tile, deltaTime float32, mapGrid [][]Tile) {
|
||||
|
||||
direction := rl.Vector3Subtract(targetPos, p.PosActual)
|
||||
distance := rl.Vector3Length(direction)
|
||||
|
||||
if distance > 1.0 {
|
||||
wasMoving := p.IsMoving
|
||||
p.IsMoving = true
|
||||
|
||||
if !wasMoving {
|
||||
p.AnimationFrame = 0
|
||||
}
|
||||
|
||||
oldFrame := p.AnimationFrame
|
||||
p.AnimationFrame += int32(deltaTime * 60)
|
||||
rl.TraceLog(rl.LogInfo, "Walk frame update: %d -> %d (delta: %f)",
|
||||
oldFrame, p.AnimationFrame, deltaTime)
|
||||
} else {
|
||||
wasMoving := p.IsMoving
|
||||
p.IsMoving = false
|
||||
|
||||
if wasMoving {
|
||||
p.AnimationFrame = 0
|
||||
}
|
||||
|
||||
oldFrame := p.AnimationFrame
|
||||
p.AnimationFrame += int32(deltaTime * 60)
|
||||
rl.TraceLog(rl.LogInfo, "Idle frame update: %d -> %d (delta: %f)",
|
||||
oldFrame, p.AnimationFrame, deltaTime)
|
||||
}
|
||||
|
||||
if distance > 0 {
|
||||
direction = rl.Vector3Scale(direction, p.Speed*deltaTime/distance)
|
||||
}
|
||||
@ -41,9 +68,12 @@ func NewPlayer(state *pb.PlayerState) *Player {
|
||||
Y: float32(state.Y * TileHeight),
|
||||
Z: float32(state.Y * TileSize),
|
||||
},
|
||||
PosTile: Tile{X: int(state.X), Y: int(state.Y)},
|
||||
Speed: 50.0,
|
||||
ID: state.PlayerId,
|
||||
PosTile: Tile{X: int(state.X), Y: int(state.Y)},
|
||||
Speed: 50.0,
|
||||
ID: state.PlayerId,
|
||||
IsMoving: false,
|
||||
AnimationFrame: 0,
|
||||
LastAnimUpdate: time.Now(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,15 +26,30 @@ type Player struct {
|
||||
ID int32
|
||||
CurrentTick int64
|
||||
LastUpdateTime time.Time
|
||||
LastAnimUpdate time.Time
|
||||
InterpolationProgress float32
|
||||
UserData interface{}
|
||||
FloatingMessage *FloatingMessage
|
||||
QuitDone chan struct{}
|
||||
AnimationFrame int32
|
||||
IsMoving bool
|
||||
}
|
||||
|
||||
type AnimationSet struct {
|
||||
Idle []rl.ModelAnimation
|
||||
Walk []rl.ModelAnimation
|
||||
// Can add more animation types later like:
|
||||
// Attack []ModelAnimation
|
||||
// Jump []ModelAnimation
|
||||
}
|
||||
|
||||
type ModelAsset struct {
|
||||
Model rl.Model
|
||||
Texture rl.Texture2D
|
||||
Model rl.Model
|
||||
Texture rl.Texture2D
|
||||
Animation []rl.ModelAnimation // Keep this for compatibility
|
||||
AnimFrames int32 // Keep this for compatibility
|
||||
Animations AnimationSet // New field for organized animations
|
||||
YOffset float32 // Additional height offset (added to default 8.0)
|
||||
}
|
||||
|
||||
type ChatMessage struct {
|
||||
|