Add idle animation
This commit is contained in:
47
game/utils/entity_types.h
Normal file
47
game/utils/entity_types.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef ENTITY_TYPES
|
||||
#define ENTITY_TYPES
|
||||
|
||||
#include <breeze.h>
|
||||
|
||||
typedef enum EntityType {
|
||||
ENTITY_WORKER = 0,
|
||||
ENTITY_AXE = 64,
|
||||
} EntityType;
|
||||
|
||||
typedef enum AnimationType {
|
||||
ANIM_WALK,
|
||||
ANIM_IDLE,
|
||||
} AnimationType;
|
||||
|
||||
typedef struct AnimationSequence {
|
||||
i32 startFrame;
|
||||
i32 frameCount;
|
||||
} AnimationSequence;
|
||||
|
||||
static bool entityHasAnimation(EntityType entity, AnimationType anim) {
|
||||
switch (entity) {
|
||||
case ENTITY_WORKER: {
|
||||
switch (anim) {
|
||||
case ANIM_IDLE:
|
||||
case ANIM_WALK:
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static AnimationSequence getEntityAnimation(EntityType entity, AnimationType anim) {
|
||||
switch (entity) {
|
||||
case ENTITY_WORKER: {
|
||||
switch (anim) {
|
||||
case ANIM_IDLE: return (AnimationSequence) {0, 2};
|
||||
case ANIM_WALK: return (AnimationSequence) {2, 4};
|
||||
}
|
||||
}
|
||||
}
|
||||
BZ_ASSERT(0);
|
||||
}
|
||||
|
||||
#endif // ENTITY_TYPES
|
||||
Reference in New Issue
Block a user