Try gooner animation
This commit is contained in:
@ -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,29 @@ 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
|
||||
}
|
||||
|
||||
type ChatMessage struct {
|
||||
|
Reference in New Issue
Block a user