add moving animation support, fix debug printing

This commit is contained in:
2024-04-16 17:46:53 +02:00
parent f2f134fddb
commit b7383f065f
7 changed files with 37 additions and 9 deletions

View File

@@ -159,24 +159,28 @@ func NewGrid(world *ecs.World,
render.Image = tile.Sprite
render.Pos = pos
if tile.Animation.OnCollision {
switch {
case tile.Animation.OnCollision:
render.CollisionAnimate.Sprites = tile.Animation.CollisionSheet.Sprites
render.CollisionAnimate.Width = tile.Animation.CollisionSheet.Width
render.CollisionAnimate.Height = tile.Animation.CollisionSheet.Height
}
if tile.Animation.OnDestruction {
case tile.Animation.OnDestruction:
render.DestructionAnimate.Sprites = tile.Animation.DestructionSheet.Sprites
render.DestructionAnimate.Width = tile.Animation.DestructionSheet.Width
render.DestructionAnimate.Height = tile.Animation.DestructionSheet.Height
}
if tile.Animation.OnIdle {
case tile.Animation.OnIdle:
render.IdleAnimate.Sprites = tile.Animation.IdleSheet.Sprites
render.IdleAnimate.Width = tile.Animation.IdleSheet.Width
render.IdleAnimate.Height = tile.Animation.IdleSheet.Height
render.StartAnimation(components.Idle)
render.Hidden = true // we do NOT render the sprite, but the idle animation instead
case tile.Animation.OnMoving:
render.MovingAnimate.Sprites = tile.Animation.IdleSheet.Sprites
render.MovingAnimate.Width = tile.Animation.IdleSheet.Width
render.MovingAnimate.Height = tile.Animation.IdleSheet.Height
}
default: