Add coomer animation lol

This commit is contained in:
bdnugget 2025-01-21 01:23:40 +01:00
parent 49b84c8540
commit 84d63ba4c1
11 changed files with 30 additions and 25 deletions

View File

@ -45,15 +45,12 @@ func LoadModels() ([]types.ModelAsset, error) {
goonerModel.Transform = transform
// Coomer model (ready for animations)
coomerModel := rl.LoadModel("resources/models/coomer.obj")
coomerTexture := rl.LoadTexture("resources/models/coomer.png")
rl.SetMaterialTexture(coomerModel.Materials, rl.MapDiffuse, coomerTexture)
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("resources/models/coomer.glb",
// map[string]string{
// "idle": "resources/models/coomer_idle.glb",
// "walk": "resources/models/coomer_walk.glb",
// })
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")
@ -69,11 +66,18 @@ func LoadModels() ([]types.ModelAsset, error) {
return []types.ModelAsset{
{
Model: goonerModel,
Animation: append(goonerAnims.Idle, goonerAnims.Walk...), // For compatibility
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: coomerModel, Texture: coomerTexture},
{Model: shrekeModel, Texture: shrekeTexture},
}, nil
}

View File

@ -154,26 +154,26 @@ 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,
}
if player.ID%int32(len(g.Models)) == 0 {
modelAsset := g.Models[0]
// 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)
}
// 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)
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -49,6 +49,7 @@ type ModelAsset struct {
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 {