2022-06-21 12:48:19 -05:00
|
|
|
#ifndef TIMER
|
|
|
|
#define TIMER
|
|
|
|
|
|
|
|
struct timer {
|
|
|
|
int timerid;
|
2022-08-22 08:55:54 -05:00
|
|
|
int on;
|
2023-11-29 17:31:41 -06:00
|
|
|
|
2023-03-05 22:05:22 -06:00
|
|
|
double interval; // Time of timer
|
2022-08-22 08:55:54 -05:00
|
|
|
int repeat;
|
2022-08-25 15:48:15 -05:00
|
|
|
double remain_time; // How much time until the timer executes
|
2022-08-22 08:55:54 -05:00
|
|
|
void (*cb)(void *data);
|
|
|
|
void *data;
|
2023-01-19 10:44:29 -06:00
|
|
|
int owndata;
|
2023-03-05 22:05:22 -06:00
|
|
|
int next;
|
2023-10-31 12:38:23 -05:00
|
|
|
int app; /* True if this timer is an "app" timer, and should always update; otherwise, only update with game time */
|
2022-06-21 12:48:19 -05:00
|
|
|
};
|
|
|
|
|
2023-09-13 07:31:00 -05:00
|
|
|
int timer_make(double interval, void (*callback)(void *param), void *param, int own, int app);
|
2023-01-18 17:15:36 -06:00
|
|
|
struct timer *id2timer(int id);
|
2023-03-17 10:25:35 -05:00
|
|
|
void timer_remove(int id);
|
2022-08-22 08:55:54 -05:00
|
|
|
void timer_start(struct timer *t);
|
|
|
|
void timer_pause(struct timer *t);
|
|
|
|
void timer_stop(struct timer *t);
|
2023-09-13 07:31:00 -05:00
|
|
|
void timer_update(double dt, double scale);
|
2022-12-16 11:54:05 -06:00
|
|
|
void timerr_settime(struct timer *t, double interval);
|
2022-06-21 12:48:19 -05:00
|
|
|
|
2023-11-07 12:45:52 -06:00
|
|
|
void timers_free();
|
|
|
|
|
2022-11-25 07:12:31 -06:00
|
|
|
#endif
|