Added a font registry, a text rendering helper, and an FPS counter function

This commit is contained in:
2026-05-06 11:12:42 -04:00
parent 284ffd7b4a
commit c3847160da
9 changed files with 81 additions and 19 deletions

View File

@@ -1,7 +1,7 @@
#ifndef _SDL_GAMECONTROLLERDB_H_
#define _SDL_GAMECONTROLLERDB_H_
// Taken from https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/refs/heads/master/gamecontrollerdb.txt on Tue May 5 08:39:19 PM EDT 2026
// Taken from https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/refs/heads/master/gamecontrollerdb.txt on Wed May 6 11:06:20 AM EDT 2026
#define SDL_GAMECONTROLLER_DB_LEN 2225

View File

@@ -4,6 +4,12 @@
#include <SDL3_mixer/SDL_mixer.h>
#include "tilemap.h"
#define GAME_AUDIO_TRACK_BGM 1
#define GAME_AUDIO_MAX_TRACKS 64
#define TIME_ONESEC_NS 1000000000
#define TIME_ONESEC_MS 1000000
/* ==================== GAME STATE VARIABLES =================== */
typedef struct {
@@ -23,11 +29,15 @@ typedef struct {
int screenwidth;
int screenheight;
GameState state;
int fps;
SDL_Time gameStartTime;
SDL_Time lastIterTime;
SDL_Time lastFPSTime;
int framesSinceUpdate;
MIX_Mixer *mixer;
MIX_Track *tracks[64];
MIX_Track *tracks[GAME_AUDIO_MAX_TRACKS];
} Game;
#define GAME_AUDIO_TRACK_BGM 1
extern SDL_Window *window;
extern SDL_Renderer *renderer;
@@ -42,5 +52,6 @@ extern Game game;
#define BITMASK_CLEAR(x) x = 0;
akerr_ErrorContext AKERR_NOIGNORE *GAME_init();
void GAME_updateFPS();
#endif //_GAME_H_

View File

@@ -8,8 +8,12 @@ extern SDL_PropertiesID REGISTRY_SPRITE;
extern SDL_PropertiesID REGISTRY_SPRITESHEET;
extern SDL_PropertiesID REGISTRY_CHARACTER;
extern SDL_PropertiesID REGISTRY_ACTOR_STATE_STRINGS;
extern SDL_PropertiesID REGISTRY_FONT;
extern SDL_PropertiesID REGISTRY_MUSIC;
akerr_ErrorContext AKERR_NOIGNORE *registry_init();
akerr_ErrorContext AKERR_NOIGNORE *registry_init_music();
akerr_ErrorContext AKERR_NOIGNORE *registry_init_font();
akerr_ErrorContext AKERR_NOIGNORE *registry_init_actor();
akerr_ErrorContext AKERR_NOIGNORE *registry_init_sprite();
akerr_ErrorContext AKERR_NOIGNORE *registry_init_spritesheet();