diff --git a/src/dusk/rpg/entity/entityanim.h b/src/dusk/rpg/entity/entityanim.h index ccd425e6..91390682 100644 --- a/src/dusk/rpg/entity/entityanim.h +++ b/src/dusk/rpg/entity/entityanim.h @@ -6,11 +6,11 @@ */ #pragma once -#include "dusk.h" +#include "time/time.h" -#define ENTITY_ANIM_TURN_DURATION 0.06f -#define ENTITY_ANIM_WALK_DURATION 0.1f -#define ENTITY_ANIM_RUN_DURATION 0.05f +#define ENTITY_ANIM_TURN_DURATION TIME_TICKS_TO_TIME(2) +#define ENTITY_ANIM_WALK_DURATION TIME_TICKS_TO_TIME(6) +#define ENTITY_ANIM_RUN_DURATION TIME_TICKS_TO_TIME(3) typedef struct entity_s entity_t; diff --git a/src/dusk/time/time.h b/src/dusk/time/time.h index a4b38f25..68f53537 100644 --- a/src/dusk/time/time.h +++ b/src/dusk/time/time.h @@ -13,6 +13,22 @@ #define DUSK_TIME_STEP (16.0f / 1000.0f) #endif +/** + * Converts a fixed-step tick count to a duration in seconds. + * + * @param ticks The number of ticks to convert. + * @return The duration in seconds. + */ +#define TIME_TICKS_TO_TIME(ticks) ((float_t)(ticks) * DUSK_TIME_STEP) + +/** + * Converts a duration in seconds to a fixed-step tick count. + * + * @param seconds The duration in seconds to convert. + * @return The number of ticks. + */ +#define TIME_TIME_TO_TICKS(seconds) ((int32_t)((seconds) / DUSK_TIME_STEP)) + #ifdef DUSK_TIME_DYNAMIC #ifndef timeTickPlatform #error "DUSK_TIME_DYNAMIC needs tick method defined"