Add types.h, standardize integer types on stdint
This commit is contained in:
@@ -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 Fri May 8 10:15:43 AM EDT 2026
|
||||
// Taken from https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/refs/heads/master/gamecontrollerdb.txt on Fri May 8 10:01:12 PM EDT 2026
|
||||
|
||||
#define AKGL_SDL_GAMECONTROLLER_DB_LEN 2227
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef _AKGL_ACTOR_H_
|
||||
#define _AKGL_ACTOR_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "types.h"
|
||||
#include "character.h"
|
||||
|
||||
// ---- LOW WORD STATUSES ----
|
||||
@@ -57,20 +59,20 @@ extern char *AKGL_ACTOR_STATE_STRING_NAMES[AKGL_ACTOR_MAX_STATES+1];
|
||||
#define AKGL_MAX_HEAP_ACTOR 64
|
||||
|
||||
typedef struct akgl_Actor {
|
||||
int refcount;
|
||||
uint8_t refcount;
|
||||
char name[AKGL_ACTOR_MAX_NAME_LENGTH];
|
||||
akgl_Character *basechar;
|
||||
int curSpriteFrameId;
|
||||
uint8_t curSpriteFrameId;
|
||||
SDL_Time curSpriteFrameTimer;
|
||||
bool curSpriteReversing;
|
||||
int layer;
|
||||
int state;
|
||||
uint32_t layer;
|
||||
int32_t state;
|
||||
bool movement_controls_face;
|
||||
void *actorData;
|
||||
bool visible;
|
||||
SDL_Time logictimer;
|
||||
float x;
|
||||
float y;
|
||||
float32_t x;
|
||||
float32_t y;
|
||||
struct akgl_Actor *children[AKGL_ACTOR_MAX_CHILDREN];
|
||||
struct akgl_Actor *parent;
|
||||
akerr_ErrorContext AKERR_NOIGNORE *(*updatefunc)(struct akgl_Actor *obj);
|
||||
|
||||
@@ -2,20 +2,21 @@
|
||||
#define _AKGL_CHARACTER_H_
|
||||
|
||||
#include <SDL3/SDL_properties.h>
|
||||
#include "types.h"
|
||||
#include "sprite.h"
|
||||
|
||||
#define AKGL_SPRITE_MAX_CHARACTER_NAME_LENGTH 128
|
||||
#define AKGL_MAX_HEAP_CHARACTER 256
|
||||
|
||||
typedef struct akgl_Character {
|
||||
int refcount;
|
||||
uint8_t refcount;
|
||||
char name[AKGL_SPRITE_MAX_CHARACTER_NAME_LENGTH];
|
||||
SDL_PropertiesID state_sprites;
|
||||
akerr_ErrorContext AKERR_NOIGNORE *(*sprite_add)(struct akgl_Character *, akgl_Sprite *, int);
|
||||
akerr_ErrorContext AKERR_NOIGNORE *(*sprite_get)(struct akgl_Character *, int, akgl_Sprite **);
|
||||
long int movementspeed;
|
||||
float vx;
|
||||
float vy;
|
||||
uint64_t movementspeed;
|
||||
float32_t vx;
|
||||
float32_t vy;
|
||||
} akgl_Character;
|
||||
|
||||
|
||||
|
||||
@@ -3,25 +3,26 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <akerror.h>
|
||||
#include "types.h"
|
||||
|
||||
#define AKGL_MAX_CONTROL_MAPS 8
|
||||
#define AKGL_MAX_CONTROLS 32
|
||||
|
||||
typedef struct {
|
||||
Uint32 event_on;
|
||||
Uint32 event_off;
|
||||
Uint8 button;
|
||||
uint32_t event_on;
|
||||
uint32_t event_off;
|
||||
uint8_t button;
|
||||
SDL_Keycode key;
|
||||
Uint8 axis;
|
||||
Uint8 axis_range_min;
|
||||
Uint8 axis_range_max;
|
||||
uint8_t axis;
|
||||
uint8_t axis_range_min;
|
||||
uint8_t axis_range_max;
|
||||
akerr_ErrorContext AKERR_NOIGNORE *(*handler_on)(akgl_Actor *obj, SDL_Event *event);
|
||||
akerr_ErrorContext AKERR_NOIGNORE *(*handler_off)(akgl_Actor *obj, SDL_Event *event);
|
||||
} akgl_Control;
|
||||
|
||||
typedef struct {
|
||||
akgl_Actor *target;
|
||||
int nextMap;
|
||||
uint16_t nextMap;
|
||||
akgl_Control controls[AKGL_MAX_CONTROLS];
|
||||
SDL_KeyboardID kbid;
|
||||
SDL_JoystickID jsid;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef _AKGL_GAME_H_
|
||||
#define _AKGL_GAME_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "types.h"
|
||||
#include <SDL3_mixer/SDL_mixer.h>
|
||||
#include "tilemap.h"
|
||||
|
||||
@@ -13,32 +15,31 @@
|
||||
/* ==================== GAME STATE VARIABLES =================== */
|
||||
|
||||
typedef struct {
|
||||
float w;
|
||||
float h;
|
||||
SDL_Texture *texture;
|
||||
float32_t w;
|
||||
float32_t h;
|
||||
SDL_Texture *texture;
|
||||
} akgl_Frame;
|
||||
|
||||
typedef struct {
|
||||
int flags;
|
||||
int32_t flags;
|
||||
} akgl_GameState;
|
||||
|
||||
typedef struct {
|
||||
char name[256];
|
||||
char version[32];
|
||||
char uri[256];
|
||||
int screenwidth;
|
||||
int screenheight;
|
||||
int16_t screenwidth;
|
||||
int16_t screenheight;
|
||||
akgl_GameState state;
|
||||
int fps;
|
||||
int16_t fps;
|
||||
SDL_Time gameStartTime;
|
||||
SDL_Time lastIterTime;
|
||||
SDL_Time lastFPSTime;
|
||||
int framesSinceUpdate;
|
||||
int16_t framesSinceUpdate;
|
||||
MIX_Mixer *mixer;
|
||||
MIX_Track *tracks[AKGL_GAME_AUDIO_MAX_TRACKS];
|
||||
} akgl_Game;
|
||||
|
||||
|
||||
extern SDL_Window *window;
|
||||
extern SDL_Renderer *renderer;
|
||||
extern akgl_Tilemap gamemap;
|
||||
@@ -53,5 +54,7 @@ extern akgl_Game game;
|
||||
|
||||
akerr_ErrorContext AKERR_NOIGNORE *akgl_game_init();
|
||||
void akgl_game_updateFPS();
|
||||
akerr_ErrorContext AKERR_NOIGNORE *akgl_game_save(char *fpath);
|
||||
akerr_ErrorContext AKERR_NOIGNORE *akgl_game_load(char *fpath);
|
||||
|
||||
#endif //_AKGL_GAME_H_
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#define _AKGL_ITERATOR_H_
|
||||
|
||||
typedef struct {
|
||||
int flags;
|
||||
int layerid;
|
||||
uint32_t flags;
|
||||
uint8_t layerid;
|
||||
} akgl_Iterator;
|
||||
|
||||
#define AKGL_ITERATOR_OP_UPDATE 1 // 1
|
||||
|
||||
@@ -20,6 +20,7 @@ akerr_ErrorContext AKERR_NOIGNORE *akgl_registry_init_sprite();
|
||||
akerr_ErrorContext AKERR_NOIGNORE *akgl_registry_init_spritesheet();
|
||||
akerr_ErrorContext AKERR_NOIGNORE *akgl_registry_init_character();
|
||||
akerr_ErrorContext AKERR_NOIGNORE *akgl_registry_init_properties();
|
||||
akerr_ErrorContext AKERR_NOIGNORE *akgl_registry_load_properties(char *fname);
|
||||
akerr_ErrorContext AKERR_NOIGNORE *akgl_registry_init_actor_state_strings();
|
||||
|
||||
|
||||
|
||||
@@ -15,24 +15,24 @@
|
||||
#define AKGL_MAX_HEAP_SPRITESHEET AKGL_MAX_HEAP_SPRITE
|
||||
|
||||
typedef struct {
|
||||
int refcount;
|
||||
SDL_Texture *texture;
|
||||
char name[AKGL_SPRITE_SHEET_MAX_FILENAME_LENGTH];
|
||||
int sprite_w;
|
||||
int sprite_h;
|
||||
uint8_t refcount;
|
||||
SDL_Texture *texture;
|
||||
char name[AKGL_SPRITE_SHEET_MAX_FILENAME_LENGTH];
|
||||
uint16_t sprite_w;
|
||||
uint16_t sprite_h;
|
||||
} akgl_SpriteSheet;
|
||||
|
||||
typedef struct {
|
||||
int refcount;
|
||||
akgl_SpriteSheet *sheet;
|
||||
int frameids[AKGL_SPRITE_MAX_FRAMES]; // which IDs on the spritesheet belong to our frames
|
||||
int frames; // how many frames are in this animation
|
||||
int width;
|
||||
int height;
|
||||
long int speed; // how many milliseconds a given sprite frame should be visible before cycling
|
||||
bool loop; // when this sprite is done playing, it should immediately start again
|
||||
bool loopReverse; // when this sprite is done playing, it should go in reverse order through its frames
|
||||
char name[AKGL_SPRITE_MAX_NAME_LENGTH];
|
||||
uint8_t refcount;
|
||||
akgl_SpriteSheet *sheet;
|
||||
uint8_t frameids[AKGL_SPRITE_MAX_FRAMES]; // which IDs on the spritesheet belong to our frames
|
||||
uint32_t frames; // how many frames are in this animation
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t speed; // how many milliseconds a given sprite frame should be visible before cycling
|
||||
bool loop; // when this sprite is done playing, it should immediately start again
|
||||
bool loopReverse; // when this sprite is done playing, it should go in reverse order through its frames
|
||||
char name[AKGL_SPRITE_MAX_NAME_LENGTH];
|
||||
} akgl_Sprite;
|
||||
|
||||
// initializes a new sprite to use the given sheet and otherwise sets to zero
|
||||
|
||||
9
include/akgl/types.h
Normal file
9
include/akgl/types.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef _AKGL_TYPES_H_
|
||||
#define _AKGL_TYPES_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef float float32_t;
|
||||
typedef double float64_t;
|
||||
|
||||
#endif // _AKGL_TYPES_H_
|
||||
Reference in New Issue
Block a user