completed animation setup and code based solely on LDTK settings

This commit is contained in:
2024-04-03 19:39:08 +02:00
parent 001b67f97a
commit f844058bf9
13 changed files with 262 additions and 172 deletions

View File

@@ -43,7 +43,7 @@ func NewLevel(game *Game, cellsize int, plan *ldtkgo.Level) *Level {
systems.NewGridSystem(game.World, game.ScreenWidth, game.ScreenHeight, cellsize,
assets.Assets[plan.PropertyByIdentifier("background").AsString()]))
systemlist = append(systemlist, systems.NewCollectibleSystem(game.World))
systemlist = append(systemlist, systems.NewCollectibleSystem(game.World, cellsize))
systemlist = append(systemlist, systems.NewObstacleSystem(game.World, gridcontainer))
@@ -198,9 +198,13 @@ func LevelToSlice(game *Game, level *ldtkgo.Level, tilesize int) (Map, Map) {
}
tileRect := entity.TileRect
animateondestruct := util.GetPropertyBool(entity, "AnimateOnDestruct")
animationtrigger := util.GetPropertyString(entity, "AnimationTrigger")
slog.Debug("got trigger", "trigger", animationtrigger)
//animateondestruct := util.GetPropertyBool(entity, "AnimateOnDestruct")
// FIXME: also check for AnimationLoop and other animation reasons
if animateondestruct {
// if animateondestruct {
if animationtrigger != "" {
tile.AnimateOnDestruct = true
animation := util.GetPropertyString(entity, "AnimateSpriteSheet")
@@ -212,6 +216,7 @@ func LevelToSlice(game *Game, level *ldtkgo.Level, tilesize int) (Map, Map) {
}
tile.AnimationSpriteSheet = assets.Animations[animation]
tile.AnimationTrigger = animationtrigger
}
tile.Sprite = tileset.SubImage(