Add named animations

This commit is contained in:
2023-12-16 16:01:39 +01:00
parent 5b6c49b2f1
commit dfe137bb93
5 changed files with 359 additions and 15 deletions

View File

@@ -251,7 +251,7 @@ static AnimationFrame terrainGetAnimationFrame(BzTileID tile, i32 frameIdx) {
case 4868: return ((AnimationFrame []) {{4868, 100}, {4869, 100}, {4870, 100}, {4871, 100}}) [frameIdx];
default:
BZ_ASSERT(0);
return (AnimationFrame) {0, 0};
return (AnimationFrame) {-1, -1.0f};
}
}
@@ -312,4 +312,68 @@ static BuildingType getBuildingSize(BuildingType type, BzTileID *outWidth, BzTil
}
typedef enum EntityType {
ENTITY_WORKER,
ENTITY_COUNT,
ENTITY_NONE,
} EntityType;
typedef enum AnimType {
ANIM_IDLE,
ANIM_WALK,
ANIM_HURT,
ANIM_DIE,
ANIM_COUNT,
ANIM_NONE,
} AnimType;
static bool entityHasAnimation(EntityType entity, AnimType type) {
switch (entity) {
case ENTITY_WORKER:
switch (type) {
case ANIM_IDLE:
case ANIM_WALK:
case ANIM_HURT:
case ANIM_DIE:
return true;
default:
return false;
}
default:
return false;
}
}
static AnimationSequence entityGetAnimationSequence(EntityType entity, AnimType type) {
switch (entity) {
case ENTITY_WORKER:
switch (type) {
case ANIM_IDLE: return (AnimationSequence) {.startFrame = 27, .frameCount = 2};
case ANIM_WALK: return (AnimationSequence) {.startFrame = 29, .frameCount = 4};
case ANIM_HURT: return (AnimationSequence) {.startFrame = 32, .frameCount = 3};
case ANIM_DIE: return (AnimationSequence) {.startFrame = 32, .frameCount = 6};
default: break;
}
default: break;
}
BZ_ASSERT(0);
return (AnimationSequence) {0, 0};
}
static AnimationFrame entityGetAnimationFrame(EntityType entity, AnimType type, i32 frameIdx) {
switch (entity) {
case ENTITY_WORKER:
switch (type) {
case ANIM_IDLE: return ((AnimationFrame []) {{27, 200}, {28, 200}}) [frameIdx];
case ANIM_WALK: return ((AnimationFrame []) {{29, 180}, {30, 180}, {31, 180}, {30, 180}}) [frameIdx];
case ANIM_HURT: return ((AnimationFrame []) {{32, 140}, {33, 140}, {34, 140}}) [frameIdx];
case ANIM_DIE: return ((AnimationFrame []) {{32, 140}, {33, 140}, {34, 140}, {36, 150}, {35, 130}, {36, 1400}}) [frameIdx];
default: break;
}
default: break;
}
BZ_ASSERT(0);
return (AnimationFrame) {-1, -1.0f};
}
#endif // GAME_TILESET_H