Time and tick helpers
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user