2026-05-06 23:18:42 -04:00
|
|
|
#ifndef _AKGL_CHARACTER_H_
|
|
|
|
|
#define _AKGL_CHARACTER_H_
|
2025-08-03 10:07:35 -04:00
|
|
|
|
|
|
|
|
#include <SDL3/SDL_properties.h>
|
|
|
|
|
#include "sprite.h"
|
|
|
|
|
|
2026-05-06 23:18:42 -04:00
|
|
|
#define AKGL_SPRITE_MAX_CHARACTER_NAME_LENGTH 128
|
|
|
|
|
#define AKGL_MAX_HEAP_CHARACTER 256
|
2025-08-03 10:07:35 -04:00
|
|
|
|
2026-05-06 23:18:42 -04:00
|
|
|
typedef struct akgl_Character {
|
2025-08-03 10:07:35 -04:00
|
|
|
int refcount;
|
2026-05-06 23:18:42 -04:00
|
|
|
char name[AKGL_SPRITE_MAX_CHARACTER_NAME_LENGTH];
|
2025-08-03 10:07:35 -04:00
|
|
|
SDL_PropertiesID state_sprites;
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *(*sprite_add)(struct akgl_Character *, akgl_Sprite *, int);
|
|
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *(*sprite_get)(struct akgl_Character *, int, akgl_Sprite **);
|
2026-05-05 20:39:58 -04:00
|
|
|
long int movementspeed;
|
2025-08-03 10:07:35 -04:00
|
|
|
float vx;
|
|
|
|
|
float vy;
|
2026-05-06 23:18:42 -04:00
|
|
|
} akgl_Character;
|
2025-08-03 10:07:35 -04:00
|
|
|
|
|
|
|
|
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_character_initialize(akgl_Character *basechar, char *name);
|
|
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_character_sprite_add(akgl_Character *basechar, akgl_Sprite *ref, int state);
|
|
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_character_sprite_get(akgl_Character *basechar, int state, akgl_Sprite **dest);
|
2025-08-03 10:07:35 -04:00
|
|
|
|
|
|
|
|
// This is an SDL iterator so we can't return our error state from it.
|
2026-05-06 23:18:42 -04:00
|
|
|
void akgl_character_state_sprites_iterate(void *userdata, SDL_PropertiesID props, const char *name);
|
2025-08-03 10:07:35 -04:00
|
|
|
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_character_load_json(char *filename);
|
2025-08-03 10:07:35 -04:00
|
|
|
|
2026-05-06 23:18:42 -04:00
|
|
|
#endif // _AKGL_CHARACTER_H_
|