Add coomer animation lol
This commit is contained in:
+14
-10
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -154,15 +154,16 @@ 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 {
|
|
||||||
modelAsset := g.Models[0]
|
|
||||||
|
|
||||||
// Check if model has animations
|
// Check if model has animations
|
||||||
if modelAsset.Animations.Idle != nil || modelAsset.Animations.Walk != nil {
|
if modelAsset.Animations.Idle != nil || modelAsset.Animations.Walk != nil {
|
||||||
if player.IsMoving && len(modelAsset.Animations.Walk) > 0 {
|
if player.IsMoving && len(modelAsset.Animations.Walk) > 0 {
|
||||||
@@ -175,7 +176,6 @@ func (g *Game) DrawPlayer(player *types.Player, model rl.Model) {
|
|||||||
rl.UpdateModelAnimation(model, anim, player.AnimationFrame)
|
rl.UpdateModelAnimation(model, anim, player.AnimationFrame)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
rl.DrawModel(model, playerPos, 16, rl.White)
|
rl.DrawModel(model, playerPos, 16, rl.White)
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user