#ifndef _AKGL_SPRITE_H_ #define _AKGL_SPRITE_H_ #include #include #include #define AKGL_SPRITE_MAX_FRAMES 16 #define AKGL_SPRITE_MAX_NAME_LENGTH 128 #define AKGL_SPRITE_MAX_REGISTRY_SIZE 1024 #define AKGL_SPRITE_SHEET_MAX_FILENAME_LENGTH 512 #define AKGL_MAX_HEAP_SPRITE (AKGL_MAX_HEAP_ACTOR * 16) #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; } 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]; } akgl_Sprite; // initializes a new sprite to use the given sheet and otherwise sets to zero akerr_ErrorContext AKERR_NOIGNORE *akgl_sprite_initialize(akgl_Sprite *spr, char *name, akgl_SpriteSheet *sheet); // loads a given image file into a new spritesheet akerr_ErrorContext AKERR_NOIGNORE *akgl_spritesheet_initialize(akgl_SpriteSheet *sheet, int sprite_w, int sprite_h, char *filename); akerr_ErrorContext AKERR_NOIGNORE *akgl_sprite_load_json(char *filename); #endif //_AKGL_SPRITE_H_