renamed particle* to animation*, added asesprite animation loading

This commit is contained in:
2024-04-02 20:05:23 +02:00
parent 20fa2639c6
commit 001b67f97a
14 changed files with 673 additions and 162 deletions

View File

@@ -2,6 +2,7 @@ package game
import (
"image"
"log"
"log/slog"
"openquell/assets"
"openquell/components"
@@ -51,7 +52,7 @@ func NewLevel(game *Game, cellsize int, plan *ldtkgo.Level) *Level {
systemlist = append(systemlist,
systems.NewPlayerSystem(game.World, gridcontainer, game.ScreenWidth, game.ScreenHeight))
systemlist = append(systemlist, systems.NewParticleSystem(game.World, game.Cellsize))
systemlist = append(systemlist, systems.NewAnimationSystem(game.World, game.Cellsize))
systemlist = append(systemlist, systems.NewTransientSystem(game.World, gridcontainer))
@@ -197,6 +198,22 @@ func LevelToSlice(game *Game, level *ldtkgo.Level, tilesize int) (Map, Map) {
}
tileRect := entity.TileRect
animateondestruct := util.GetPropertyBool(entity, "AnimateOnDestruct")
// FIXME: also check for AnimationLoop and other animation reasons
if animateondestruct {
tile.AnimateOnDestruct = true
animation := util.GetPropertyString(entity, "AnimateSpriteSheet")
if animation != "" {
if !util.Exists(assets.Animations, animation) {
log.Fatalf("entity %s refers to non existent animation set %s",
entity.Identifier, animation)
}
}
tile.AnimationSpriteSheet = assets.Animations[animation]
}
tile.Sprite = tileset.SubImage(
image.Rect(tileRect.X, tileRect.Y,
tileRect.X+tileRect.W,