Add coomer animation lol
This commit is contained in:
parent
49b84c8540
commit
84d63ba4c1
@ -45,15 +45,12 @@ func LoadModels() ([]types.ModelAsset, error) {
|
|||||||
goonerModel.Transform = transform
|
goonerModel.Transform = transform
|
||||||
|
|
||||||
// Coomer model (ready for animations)
|
// Coomer model (ready for animations)
|
||||||
coomerModel := rl.LoadModel("resources/models/coomer.obj")
|
coomerModel := rl.LoadModel("resources/models/coomer/idle_notransy.glb")
|
||||||
coomerTexture := rl.LoadTexture("resources/models/coomer.png")
|
// coomerTexture := rl.LoadTexture("resources/models/coomer.png")
|
||||||
rl.SetMaterialTexture(coomerModel.Materials, rl.MapDiffuse, coomerTexture)
|
// rl.SetMaterialTexture(coomerModel.Materials, rl.MapDiffuse, coomerTexture)
|
||||||
// When you have animations, add them like:
|
// When you have animations, add them like:
|
||||||
// coomerAnims, _ := loadModelAnimations("resources/models/coomer.glb",
|
coomerAnims, _ := loadModelAnimations(map[string]string{"idle": "resources/models/coomer/idle_notransy.glb", "walk": "resources/models/coomer/unsteadywalk_notransy.glb"})
|
||||||
// map[string]string{
|
coomerModel.Transform = transform
|
||||||
// "idle": "resources/models/coomer_idle.glb",
|
|
||||||
// "walk": "resources/models/coomer_walk.glb",
|
|
||||||
// })
|
|
||||||
|
|
||||||
// Shreke model (ready for animations)
|
// Shreke model (ready for animations)
|
||||||
shrekeModel := rl.LoadModel("resources/models/shreke.obj")
|
shrekeModel := rl.LoadModel("resources/models/shreke.obj")
|
||||||
@ -69,11 +66,18 @@ func LoadModels() ([]types.ModelAsset, error) {
|
|||||||
return []types.ModelAsset{
|
return []types.ModelAsset{
|
||||||
{
|
{
|
||||||
Model: goonerModel,
|
Model: goonerModel,
|
||||||
Animation: append(goonerAnims.Idle, goonerAnims.Walk...), // For compatibility
|
Animation: append(goonerAnims.Idle, goonerAnims.Walk...),
|
||||||
AnimFrames: int32(len(goonerAnims.Idle) + len(goonerAnims.Walk)),
|
AnimFrames: int32(len(goonerAnims.Idle) + len(goonerAnims.Walk)),
|
||||||
Animations: goonerAnims,
|
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: coomerModel, Texture: coomerTexture},
|
|
||||||
{Model: shrekeModel, Texture: shrekeTexture},
|
{Model: shrekeModel, Texture: shrekeTexture},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
30
game/game.go
30
game/game.go
@ -154,26 +154,26 @@ func (g *Game) DrawPlayer(player *types.Player, model rl.Model) {
|
|||||||
defer player.Unlock()
|
defer player.Unlock()
|
||||||
|
|
||||||
grid := GetMapGrid()
|
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{
|
playerPos := rl.Vector3{
|
||||||
X: player.PosActual.X,
|
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,
|
Z: player.PosActual.Z,
|
||||||
}
|
}
|
||||||
|
|
||||||
if player.ID%int32(len(g.Models)) == 0 {
|
// Check if model has animations
|
||||||
modelAsset := g.Models[0]
|
if modelAsset.Animations.Idle != nil || modelAsset.Animations.Walk != nil {
|
||||||
|
if player.IsMoving && len(modelAsset.Animations.Walk) > 0 {
|
||||||
// Check if model has animations
|
anim := modelAsset.Animations.Walk[0] // Use first walk animation
|
||||||
if modelAsset.Animations.Idle != nil || modelAsset.Animations.Walk != nil {
|
player.AnimationFrame = player.AnimationFrame % anim.FrameCount
|
||||||
if player.IsMoving && len(modelAsset.Animations.Walk) > 0 {
|
rl.UpdateModelAnimation(model, anim, player.AnimationFrame)
|
||||||
anim := modelAsset.Animations.Walk[0] // Use first walk animation
|
} else if len(modelAsset.Animations.Idle) > 0 {
|
||||||
player.AnimationFrame = player.AnimationFrame % anim.FrameCount
|
anim := modelAsset.Animations.Idle[0] // Use first idle animation
|
||||||
rl.UpdateModelAnimation(model, anim, player.AnimationFrame)
|
player.AnimationFrame = player.AnimationFrame % anim.FrameCount
|
||||||
} else if len(modelAsset.Animations.Idle) > 0 {
|
rl.UpdateModelAnimation(model, anim, player.AnimationFrame)
|
||||||
anim := modelAsset.Animations.Idle[0] // Use first idle animation
|
|
||||||
player.AnimationFrame = player.AnimationFrame % anim.FrameCount
|
|
||||||
rl.UpdateModelAnimation(model, anim, player.AnimationFrame)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
resources/models/coomer/Animation_Confused_Scratch_withSkin.glb
Normal file
BIN
resources/models/coomer/Animation_Confused_Scratch_withSkin.glb
Normal file
Binary file not shown.
BIN
resources/models/coomer/Animation_Idle_withSkin.glb
Normal file
BIN
resources/models/coomer/Animation_Idle_withSkin.glb
Normal file
Binary file not shown.
BIN
resources/models/coomer/Animation_Running_withSkin.glb
Normal file
BIN
resources/models/coomer/Animation_Running_withSkin.glb
Normal file
Binary file not shown.
BIN
resources/models/coomer/Animation_Unsteady_Walk_withSkin.glb
Normal file
BIN
resources/models/coomer/Animation_Unsteady_Walk_withSkin.glb
Normal file
Binary file not shown.
BIN
resources/models/coomer/Animation_Walking_withSkin.glb
Normal file
BIN
resources/models/coomer/Animation_Walking_withSkin.glb
Normal file
Binary file not shown.
BIN
resources/models/coomer/idle_notransy.glb
Normal file
BIN
resources/models/coomer/idle_notransy.glb
Normal file
Binary file not shown.
BIN
resources/models/coomer/unsteadywalk_notransy.glb
Normal file
BIN
resources/models/coomer/unsteadywalk_notransy.glb
Normal file
Binary file not shown.
BIN
resources/models/coomerAnim.zip
Normal file
BIN
resources/models/coomerAnim.zip
Normal file
Binary file not shown.
@ -49,6 +49,7 @@ type ModelAsset struct {
|
|||||||
Animation []rl.ModelAnimation // Keep this for compatibility
|
Animation []rl.ModelAnimation // Keep this for compatibility
|
||||||
AnimFrames int32 // Keep this for compatibility
|
AnimFrames int32 // Keep this for compatibility
|
||||||
Animations AnimationSet // New field for organized animations
|
Animations AnimationSet // New field for organized animations
|
||||||
|
YOffset float32 // Additional height offset (added to default 8.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChatMessage struct {
|
type ChatMessage struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user