Very basic animations

This commit is contained in:
2023-11-12 18:03:55 +01:00
parent bf56b150cc
commit 526d292fb5
9 changed files with 95 additions and 6 deletions

View File

@@ -22,6 +22,7 @@ bool initEntityObjectsLayer(BzTileMap *map, BzTileObjectGroup *objectGroup) {
ECS_COMPONENT(ECS, Size);
ECS_COMPONENT(ECS, Rotation);
ECS_COMPONENT(ECS, TextureRegion);
ECS_COMPONENT(ECS, Animation);
BzTileset *objectTileset = bzTileObjectGroupGetTileset(&GAME->map, objectGroup);
if (!objectTileset) return true;
@@ -33,6 +34,16 @@ bool initEntityObjectsLayer(BzTileMap *map, BzTileObjectGroup *objectGroup) {
ecs_set(ECS, e, Size, {object.shape.sizeX, object.shape.sizeY});
ecs_set(ECS, e, Rotation, {0.0f});
ecs_set(ECS, e, TextureRegion, {objectTileset->tiles, bzTilesetGetTileRegion(objectTileset, object.gid)});
ecs_set(ECS, e, Animation, {
.firstFrame=(TextureRegion) {
objectTileset->tiles,
bzTilesetGetTileRegion(objectTileset, object.gid)
},
.currAnimation=ANIMATION_IDLE,
.currFrame=0,
.frameCount=2,
.frameDuration=0.36f
});
}
return true;