reorganization of twn_util.h, reletion of some seldom used procedures

This commit is contained in:
veclavtalica
2025-02-20 13:48:44 +03:00
parent 723ccf1126
commit f044a75ffe
4 changed files with 13 additions and 86 deletions

View File

@ -7,19 +7,18 @@
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846264338327950288 /**< pi */
#endif
/* multiply by these to convert degrees <---> radians */
#define DEG2RAD (M_PI / 180)
#define RAD2DEG (180 / M_PI)
/* TODO: shouldn't be a thing */
#ifndef TWN_NOT_C
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846264338327950288 /**< pi */
#endif
/* multiply by these to convert degrees <---> radians */
#define DEG2RAD (M_PI / 180)
#define RAD2DEG (180 / M_PI)
TWN_API void log_info(const char *restrict format, ...);
TWN_API void log_critical(const char *restrict format, ...);
@ -28,13 +27,8 @@
/* saves all texture atlases as BMP files in the write directory */
TWN_API void textures_dump_atlases(void);
/* returns true if str ends with suffix */
TWN_API bool strends(const char *str, const char *suffix);
/* TODO: this is why generics were invented. sorry, i'm tired today */
TWN_API double clamp(double d, double min, double max);
TWN_API float clampf(float f, float min, float max);
TWN_API int clampi(int i, int min, int max);
/* sets buf_out to a pointer to a byte buffer which must be freed. */
/* returns the size of this buffer. */
@ -52,26 +46,12 @@
TWN_API Rect rect_overlap(Rect a, Rect b);
/* returns true if two rectangles are intersecting */
TWN_API bool rect_intersects(Rect a, Rect b);
TWN_API Vec2 rect_center(Rect rect);
/* decrements an integer value, stopping at 0 */
/* meant for tick-based timers in game logic */
/*
* example:
* tick_timer(&player->jump_air_timer);
*/
TWN_API int32_t timer_tick_frames(int32_t frames_left);
/* decrements a floating point second-based timer, stopping at 0.0f */
/* meant for poll based real time logic in game logic */
/* note that it should be decremented only on the next tick after its creation */
TWN_API float timer_tick_seconds(float seconds_left);
typedef struct TimerElapseFramesResult {
bool elapsed; int32_t frames_left;
} TimerElapseFramesResult;
TWN_API TimerElapseFramesResult timer_elapse_frames(int32_t frames_left, int32_t interval);
typedef struct TimerElapseSecondsResult {
bool elapsed; float seconds_left;
} TimerElapseSecondsResult;
@ -83,6 +63,5 @@ TWN_API void log_rect(Rect value, char const *identity);
TWN_API void profile_start(char const *profile);
TWN_API void profile_end(char const *profile);
TWN_API void profile_list_stats(void);
#endif