35 lines
1.0 KiB
C
35 lines
1.0 KiB
C
#ifndef ENGINE_TIMING_H
|
|
#define ENGINE_TIMING_H
|
|
#include <stdbool.h>
|
|
// Proper timer management in next version
|
|
|
|
// A periodically-increasing counter
|
|
typedef struct ManualCounter {
|
|
// How long before increasing a count
|
|
// Negative period is not allowed.
|
|
float period;
|
|
float fractional;
|
|
int count;
|
|
} ManualCounter;
|
|
|
|
bool set_counter_period(ManualCounter* counter, float period);
|
|
void elapse_counter_time(ManualCounter* counter, float delta);
|
|
void reset_counter_count(ManualCounter* counter);
|
|
void reset_counter(ManualCounter* counter);
|
|
|
|
// Frame timer, usually for animation
|
|
typedef struct FrameTimer {
|
|
ManualCounter counter;
|
|
int frame_count_period;
|
|
int frame_max_count;
|
|
int frame_count;
|
|
bool pause;
|
|
bool has_elapsed;
|
|
} FrameTimer;
|
|
|
|
bool set_frame_timings(FrameTimer* timer, float frame_time, int count_period, int max_count);
|
|
void elapse_frame_time(FrameTimer* timer, float delta);
|
|
void reset_frame_count(FrameTimer* timer);
|
|
void reset_frame_timer(FrameTimer* timer);
|
|
#endif // ENGINE_TIMING_H
|