Nilorea Library
C utilities for networking, threading, graphics
GRAPHICS: animation library, loading structures and blit funcs

Data Structures

struct  ANIM_DATA
 animation properties More...
 
struct  ANIM_FRAME
 struct of the properties of a frame in an animation More...
 
struct  ANIM_GFX
 struct of an animation More...
 
struct  ANIM_LIB
 structure of a library of gfxs More...
 

Functions

int add_bmp_to_lib (ANIM_LIB *lib, unsigned int pos, char *file, char *resfile)
 add a bitmap to a ANIM_LIB *lib More...
 
ANIM_LIBcreate_anim_library (char *name, unsigned int size)
 Allocate an animation library. More...
 
int delete_bmp_from_lib (ANIM_LIB *lib, unsigned int id)
 Delete the frame at 'id' from 'lib'. More...
 
int destroy_anim_lib (ANIM_LIB **lib)
 Destroy an animation library. More...
 
int draw_anim (ANIM_DATA *data, int x, int y)
 blit an ANIM_DATA at position x,y ( current selected video buffer is used ) More...
 
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 More...
 

Detailed Description


Data Structure Documentation

◆ ANIM_DATA

struct ANIM_DATA

animation properties

Definition at line 66 of file n_anim.h.

+ Collaboration diagram for ANIM_DATA:
Data Fields
unsigned int elapsed elapsed time since last frame change
unsigned int frame id of the current frame
unsigned int id
ANIM_LIB * lib pointer to an anim gfx library
unsigned int x x coordinate of the animation
unsigned int y y coordinate of the animation

◆ ANIM_FRAME

struct ANIM_FRAME

struct of the properties of a frame in an animation

Definition at line 26 of file n_anim.h.

+ Collaboration diagram for ANIM_FRAME:
Data Fields
unsigned int duration
int x
int y

◆ ANIM_GFX

struct ANIM_GFX

struct of an animation

Definition at line 34 of file n_anim.h.

+ Collaboration diagram for ANIM_GFX:
Data Fields
ALLEGRO_BITMAP * bmp bitmap with a list of lil' bitmap inside
ANIM_FRAME * frames each frame properties
unsigned int h height of a frame
unsigned int nb_frames nb frames in anim
unsigned int type blit type: masked with color, blended, brut
unsigned int w width of a frame

◆ ANIM_LIB

struct ANIM_LIB

structure of a library of gfxs

Definition at line 52 of file n_anim.h.

+ Collaboration diagram for ANIM_LIB:
Data Fields
ANIM_GFX ** gfxs Stack of gfxs.
char * name name of the anim library
unsigned int nb_max_gfxs size of the stack

Function Documentation

◆ add_bmp_to_lib()

int add_bmp_to_lib ( ANIM_LIB lib,
unsigned int  pos,
char *  file,
char *  resfile 
)

add a bitmap to a ANIM_LIB *lib

Parameters
libtargetted library
posposition in the animation library
fileinput bitmap file
resfileassociated input bitmap text file
Returns
TRUE or FALSE

Definition at line 94 of file n_anim.c.

References __n_assert, LOG_ERR, Malloc, and n_log.

◆ create_anim_library()

ANIM_LIB * create_anim_library ( char *  name,
unsigned int  size 
)

Allocate an animation library.

Parameters
nameName for the library or NULL (in which case 'generic_name' will be assigned)
sizeNumber of animations
Returns
An allocated ANIM_LIB *object or NULL

Definition at line 19 of file n_anim.c.

References __n_assert, LOG_ERR, Malloc, and n_log.

◆ delete_bmp_from_lib()

int delete_bmp_from_lib ( ANIM_LIB lib,
unsigned int  id 
)

Delete the frame at 'id' from 'lib'.

Parameters
libTarget animation stream
idId of the frame to delete
Returns
TRUE or FALSE

Definition at line 75 of file n_anim.c.

References __n_assert.

◆ destroy_anim_lib()

int destroy_anim_lib ( ANIM_LIB **  lib)

Destroy an animation library.

Parameters
libanimation library to destroy
Returns
TRUE or FALSE

Definition at line 56 of file n_anim.c.

References __n_assert, Free, and FreeNoLog.

◆ draw_anim()

int draw_anim ( ANIM_DATA data,
int  x,
int  y 
)

blit an ANIM_DATA at position x,y ( current selected video buffer is used )

Parameters
dataANIM_DATA *source to use
xx position on screen
yy position on screen
Returns
TRUE or FALSE

Definition at line 181 of file n_anim.c.

◆ update_anim()

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

Parameters
datatargetted ANIM_DATA
delta_telapsed time to apply (usecs)
Returns
TRUE or FALSE

Definition at line 158 of file n_anim.c.

References __n_assert.