Added aliases with sizes for the integer and floating-point numbers
This commit is contained in:
1 parent
45f6021f82
commit
5e6211c2a9
14 files changed
+146
-136
No files matched your search
+41
-44
@@ -22,8 +22,6 @@
|
||||
#include "engine_build_config.h"
|
||||
#include "reusable_ids.h"
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -33,8 +31,8 @@
|
||||
|
||||
INTERNAL struct game_engine {
|
||||
bool running;
|
||||
float delta;
|
||||
uint64_t last_time;
|
||||
f32 delta;
|
||||
u64 last_time;
|
||||
Window window;
|
||||
SDL_Event event;
|
||||
ObjectStore *object_store;
|
||||
@@ -43,7 +41,7 @@ INTERNAL struct game_engine {
|
||||
|
||||
bool init_engine(const char *game_name, WindowSize window_size,
|
||||
SDL_Color window_background_color, bool full_screen,
|
||||
uint8_t audio_tracks) {
|
||||
u8 audio_tracks) {
|
||||
bool initialisation_complete = true;
|
||||
const char *current_platform = SDL_GetPlatform();
|
||||
|
||||
@@ -59,7 +57,7 @@ bool init_engine(const char *game_name, WindowSize window_size,
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t img_flags = IMG_INIT_PNG;
|
||||
u32 img_flags = IMG_INIT_PNG;
|
||||
if (strcmp(current_platform, "Android") != 0) {
|
||||
// Apparently, Android devices don't support TIFF images, so we only enable
|
||||
// TIFF support when we are not running Android.
|
||||
@@ -177,7 +175,7 @@ void close_engine() {
|
||||
#endif /* DEBUG_ENGINE */
|
||||
}
|
||||
|
||||
int64_t get_time() { return SDL_GetTicks64(); }
|
||||
i64 get_time() { return SDL_GetTicks64(); }
|
||||
|
||||
ObjectID add_object(void *object, EventHandlerPtr event_handler,
|
||||
UpdateFuncPtr update_func, RenderFuncPtr render_func) {
|
||||
@@ -252,10 +250,10 @@ void clip_render_rects_to_drawing_area(RenderRect *src, RenderRect *dest) {
|
||||
return;
|
||||
}
|
||||
|
||||
float x_offset = 0.0f;
|
||||
float y_offset = 0.0f;
|
||||
float x_clip = 0.0f;
|
||||
float y_clip = 0.0f;
|
||||
f32 x_offset = 0.0f;
|
||||
f32 y_offset = 0.0f;
|
||||
f32 x_clip = 0.0f;
|
||||
f32 y_clip = 0.0f;
|
||||
|
||||
// If the rectangle is partially out of the horizontal bounds of the drawing
|
||||
// area, calculate how much of its width will be clipped
|
||||
@@ -302,8 +300,8 @@ RenderRect get_texture_asset_rect(AssetID id) {
|
||||
SDL_Texture *texture = get_texture(GameEngine.asset_manager, id);
|
||||
|
||||
if (texture) {
|
||||
int32_t w = 0;
|
||||
int32_t h = 0;
|
||||
i32 w = 0;
|
||||
i32 h = 0;
|
||||
if (SDL_QueryTexture(texture, NULL, NULL, &w, &h) == 0) {
|
||||
rect.width = w;
|
||||
rect.height = h;
|
||||
@@ -344,7 +342,7 @@ TextSize get_text_size_from_font_asset(AssetID id, const char *text) {
|
||||
return output;
|
||||
}
|
||||
|
||||
void render_text_with_font_asset(AssetID id, const char *text, float x, float y,
|
||||
void render_text_with_font_asset(AssetID id, const char *text, f32 x, f32 y,
|
||||
SDL_Color color) {
|
||||
if (id < 0) {
|
||||
return;
|
||||
@@ -361,8 +359,8 @@ void render_text_with_font_asset(AssetID id, const char *text, float x, float y,
|
||||
}
|
||||
|
||||
// Get the width and height, in pixels, of the text rendered using the font
|
||||
int32_t w = 0;
|
||||
int32_t h = 0;
|
||||
i32 w = 0;
|
||||
i32 h = 0;
|
||||
TTF_SizeText(font, text, &w, &h);
|
||||
|
||||
RenderRect rect = {x, y, w, h};
|
||||
@@ -373,7 +371,7 @@ void render_text_with_font_asset(AssetID id, const char *text, float x, float y,
|
||||
surface = NULL;
|
||||
}
|
||||
|
||||
void set_font_asset_size(AssetID id, uint32_t size) {
|
||||
void set_font_asset_size(AssetID id, u32 size) {
|
||||
if (id < 0) {
|
||||
return;
|
||||
}
|
||||
@@ -386,8 +384,8 @@ void set_font_asset_size(AssetID id, uint32_t size) {
|
||||
TTF_SetFontSize(font, size);
|
||||
}
|
||||
|
||||
int8_t play_audio_asset(AssetID id, int16_t loops, bool fade_in,
|
||||
uint32_t fade_length_in_ms) {
|
||||
i8 play_audio_asset(AssetID id, i16 loops, bool fade_in,
|
||||
u32 fade_length_in_ms) {
|
||||
if (id < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -404,7 +402,7 @@ int8_t play_audio_asset(AssetID id, int16_t loops, bool fade_in,
|
||||
}
|
||||
}
|
||||
|
||||
void pause_audio_asset_on_track(AssetID id, uint8_t track) {
|
||||
void pause_audio_asset_on_track(AssetID id, u8 track) {
|
||||
if (id < 0) {
|
||||
return;
|
||||
}
|
||||
@@ -417,7 +415,7 @@ void pause_audio_asset_on_track(AssetID id, uint8_t track) {
|
||||
Mix_Pause(track);
|
||||
}
|
||||
|
||||
void resume_audio_asset_on_track(AssetID id, uint8_t track) {
|
||||
void resume_audio_asset_on_track(AssetID id, u8 track) {
|
||||
if (id < 0) {
|
||||
return;
|
||||
}
|
||||
@@ -430,7 +428,7 @@ void resume_audio_asset_on_track(AssetID id, uint8_t track) {
|
||||
Mix_Resume(track);
|
||||
}
|
||||
|
||||
void stop_audio_asset_on_track(AssetID id, uint8_t track) {
|
||||
void stop_audio_asset_on_track(AssetID id, u8 track) {
|
||||
if (id < 0) {
|
||||
return;
|
||||
}
|
||||
@@ -443,8 +441,8 @@ void stop_audio_asset_on_track(AssetID id, uint8_t track) {
|
||||
Mix_HaltChannel(track);
|
||||
}
|
||||
|
||||
void fade_out_audio_asset_on_track(AssetID id, uint8_t track,
|
||||
uint32_t fade_length_in_ms) {
|
||||
void fade_out_audio_asset_on_track(AssetID id, u8 track,
|
||||
u32 fade_length_in_ms) {
|
||||
if (id < 0) {
|
||||
return;
|
||||
}
|
||||
@@ -467,9 +465,9 @@ void pause_all_instances_of_audio_asset(AssetID id) {
|
||||
return;
|
||||
}
|
||||
|
||||
size_t channel_count = Mix_AllocateChannels(-1);
|
||||
u64 channel_count = Mix_AllocateChannels(-1);
|
||||
|
||||
for (size_t i = 0; i < channel_count; ++i) {
|
||||
for (u64 i = 0; i < channel_count; ++i) {
|
||||
if (chunk == Mix_GetChunk(i)) {
|
||||
Mix_Pause(i);
|
||||
}
|
||||
@@ -486,9 +484,9 @@ void resume_all_instances_of_audio_asset(AssetID id) {
|
||||
return;
|
||||
}
|
||||
|
||||
size_t channel_count = Mix_AllocateChannels(-1);
|
||||
u64 channel_count = Mix_AllocateChannels(-1);
|
||||
|
||||
for (size_t i = 0; i < channel_count; ++i) {
|
||||
for (u64 i = 0; i < channel_count; ++i) {
|
||||
if (chunk == Mix_GetChunk(i)) {
|
||||
Mix_Resume(i);
|
||||
}
|
||||
@@ -505,17 +503,16 @@ void stop_all_instances_of_audio_asset(AssetID id) {
|
||||
return;
|
||||
}
|
||||
|
||||
size_t channel_count = Mix_AllocateChannels(-1);
|
||||
u64 channel_count = Mix_AllocateChannels(-1);
|
||||
|
||||
for (size_t i = 0; i < channel_count; ++i) {
|
||||
for (u64 i = 0; i < channel_count; ++i) {
|
||||
if (chunk == Mix_GetChunk(i)) {
|
||||
Mix_HaltChannel(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void fade_out_all_instances_of_audio_asset(AssetID id,
|
||||
uint32_t fade_length_in_ms) {
|
||||
void fade_out_all_instances_of_audio_asset(AssetID id, u32 fade_length_in_ms) {
|
||||
if (id < 0) {
|
||||
return;
|
||||
}
|
||||
@@ -525,16 +522,16 @@ void fade_out_all_instances_of_audio_asset(AssetID id,
|
||||
return;
|
||||
}
|
||||
|
||||
size_t channel_count = Mix_AllocateChannels(-1);
|
||||
u64 channel_count = Mix_AllocateChannels(-1);
|
||||
|
||||
for (size_t i = 0; i < channel_count; ++i) {
|
||||
for (u64 i = 0; i < channel_count; ++i) {
|
||||
if (chunk == Mix_GetChunk(i)) {
|
||||
Mix_FadeOutChannel(i, fade_length_in_ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int8_t get_audio_asset_volume(AssetID id) {
|
||||
i8 get_audio_asset_volume(AssetID id) {
|
||||
if (id < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -547,7 +544,7 @@ int8_t get_audio_asset_volume(AssetID id) {
|
||||
return chunk->volume;
|
||||
}
|
||||
|
||||
void set_audio_asset_volume(AssetID id, int8_t volume) {
|
||||
void set_audio_asset_volume(AssetID id, i8 volume) {
|
||||
if (id < 0) {
|
||||
return;
|
||||
}
|
||||
@@ -560,8 +557,8 @@ void set_audio_asset_volume(AssetID id, int8_t volume) {
|
||||
Mix_VolumeChunk(chunk, volume);
|
||||
}
|
||||
|
||||
void play_music_asset(AssetID id, int16_t loops, bool fade_in,
|
||||
uint32_t fade_length_in_ms) {
|
||||
void play_music_asset(AssetID id, i16 loops, bool fade_in,
|
||||
u32 fade_length_in_ms) {
|
||||
if (id < 0 || is_music_asset_playing(id)) {
|
||||
return;
|
||||
}
|
||||
@@ -617,7 +614,7 @@ void stop_music_asset(AssetID id) {
|
||||
Mix_HaltMusic();
|
||||
}
|
||||
|
||||
void fade_out_music_asset(AssetID id, uint32_t fade_length_in_ms) {
|
||||
void fade_out_music_asset(AssetID id, u32 fade_length_in_ms) {
|
||||
if (id < 0 || !is_music_asset_playing(id)) {
|
||||
return;
|
||||
}
|
||||
@@ -630,7 +627,7 @@ void fade_out_music_asset(AssetID id, uint32_t fade_length_in_ms) {
|
||||
Mix_FadeOutMusic(fade_length_in_ms);
|
||||
}
|
||||
|
||||
int8_t get_music_asset_volume(AssetID id) {
|
||||
i8 get_music_asset_volume(AssetID id) {
|
||||
if (id < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -643,7 +640,7 @@ int8_t get_music_asset_volume(AssetID id) {
|
||||
return Mix_GetMusicVolume(music);
|
||||
}
|
||||
|
||||
void set_music_asset_volume(AssetID id, int8_t volume) {
|
||||
void set_music_asset_volume(AssetID id, i8 volume) {
|
||||
if (id < 0 || !is_music_asset_playing(id)) {
|
||||
return;
|
||||
}
|
||||
@@ -693,11 +690,11 @@ void resume_playing_music() { Mix_ResumeMusic(); }
|
||||
|
||||
void stop_playing_music() { Mix_HaltMusic(); }
|
||||
|
||||
void fade_out_playing_music(uint32_t fade_length_in_ms) {
|
||||
void fade_out_playing_music(u32 fade_length_in_ms) {
|
||||
Mix_FadeOutMusic(fade_length_in_ms);
|
||||
}
|
||||
|
||||
void set_playing_music_volume(int8_t volume) { Mix_VolumeMusic(volume); }
|
||||
void set_playing_music_volume(i8 volume) { Mix_VolumeMusic(volume); }
|
||||
|
||||
bool is_music_playing() { return Mix_PlayingMusic(); }
|
||||
|
||||
@@ -726,7 +723,7 @@ void update() {
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t current_time = SDL_GetTicks64();
|
||||
u64 current_time = SDL_GetTicks64();
|
||||
|
||||
// Get the delta time in seconds since the SDL_GetTicks64() returns the
|
||||
// time in milliseconds
|
||||
|
||||
Reference in new issue
Block a user