21 n_log(
LOG_ERR,
"Invalid size (<1) for anim lib creation");
32 n_log(
LOG_ERR,
"Unable to allocate a gfx_lib of size %d", size);
37 lib->
name = strdup(name);
39 lib->
name = strdup(
"generic-name");
54 for (uint32_t it = 0; it < (*lib)->nb_max_gfxs; it++) {
92 if (lib->
gfxs[pos] != NULL) {
93 n_log(
LOG_ERR,
"there already is a gfx at pos %d in anim lib %s", pos, lib->
name);
97 FILE* data = fopen(resfile,
"r");
104 int check_fscanf = 0;
107 check_fscanf = fscanf(data,
"%d", &check_id);
108 if (check_fscanf == 1 && check_id == 211282) {
112 n_log(
LOG_ERR,
"file %s: invalid check_id of %d, should be 211282", resfile, check_id);
117 if (fscanf(data,
"%d %d %d", &gfx->
w, &gfx->
h, &gfx->
nb_frames) != 3) {
118 n_log(
LOG_ERR,
"file %s: invalid &gfx -> w, &gfx -> h, &gfx -> nb_frames !", resfile);
139 gfx->
bmp = al_load_bitmap(file);
147 for (
unsigned int it = 0; it < gfx->
nb_frames; it++) {
149 n_log(
LOG_ERR,
"file %s: invalid &gfx -> frames[ %d ].x, &gfx -> frames[ %d ].y, &gfx -> frames[ %d ] . duration !", resfile, it, it, it);
157 lib->
gfxs[pos] = gfx;
191 unsigned int tilew = data->
lib->
gfxs[data->
id]->
w;
192 unsigned int tileh = data->
lib->
gfxs[data->
id]->
h;
197 unsigned int framex = data->
frame * tilew;
199 al_draw_bitmap_region(bmp, framex, 0, tilew, tileh, x - px, y - py, 0);
unsigned int nb_frames
nb frames in anim
unsigned int w
width of a frame
unsigned int elapsed
elapsed time since last frame change
char * name
name of the anim library
ANIM_GFX ** gfxs
Stack of gfxs.
unsigned int h
height of a frame
ANIM_FRAME * frames
each frame properties
unsigned int frame
id of the current frame
ALLEGRO_BITMAP * bmp
bitmap with a list of lil' bitmap inside
ANIM_LIB * lib
pointer to an anim gfx library
unsigned int nb_max_gfxs
size of the stack
int delete_bmp_from_lib(ANIM_LIB *lib, unsigned int id)
Delete the frame at 'id' from 'lib'.
int add_bmp_to_lib(ANIM_LIB *lib, unsigned int pos, char *file, char *resfile)
add a bitmap to a ANIM_LIB *lib
int draw_anim(ANIM_DATA *data, int x, int y)
blit an ANIM_DATA at position x,y ( current selected video buffer is used )
ANIM_LIB * create_anim_library(char *name, unsigned int size)
Allocate an animation library.
int update_anim(ANIM_DATA *data, unsigned int delta_t)
compute and update an ANIM_DATA context based on elapsed delta_t time in usecs
int destroy_anim_lib(ANIM_LIB **lib)
Destroy an animation library.
struct of the properties of a frame in an animation
structure of a library of gfxs
#define FreeNoLog(__ptr)
Free Handler without log.
#define Malloc(__ptr, __struct, __size)
Malloc Handler to get errors and set to 0.
#define __n_assert(__ptr, __ret)
macro to assert things
#define Free(__ptr)
Free Handler to get errors.
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_ERR
error conditions
Animations graphics and animations parameters.