Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_anim.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
27#ifndef __N_ANIM_HEADER
28#define __N_ANIM_HEADER
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#include "n_common.h"
35#include "n_log.h"
36#include "n_str.h"
37#include "allegro5/allegro.h"
38
45typedef struct ANIM_FRAME {
46 int x,
48 unsigned int duration;
50
52typedef struct ANIM_GFX {
56 ALLEGRO_BITMAP* bmp;
57
59 unsigned int type,
66} ANIM_GFX;
67
69typedef struct ANIM_LIB {
72
74 unsigned int nb_max_gfxs;
75
77 char* name;
78} ANIM_LIB;
79
81typedef struct ANIM_DATA {
82 unsigned int id,
91
94} ANIM_DATA;
95
97ANIM_LIB* create_anim_library(const char* name, unsigned int size);
99int delete_bmp_from_lib(ANIM_LIB* lib, unsigned int id);
101int add_bmp_to_lib(ANIM_LIB* lib, unsigned int pos, char* file, char* resfile);
103int update_anim(ANIM_DATA* data, unsigned int delta_t);
105int draw_anim(ANIM_DATA* data, int x, int y);
107int destroy_anim_lib(ANIM_LIB** lib);
108
113#ifdef __cplusplus
114}
115#endif
116
117#endif // header guard
unsigned int nb_frames
nb frames in anim
Definition n_anim.h:65
unsigned int type
blit type: masked with color, blended, brut
Definition n_anim.h:59
int y
Definition n_anim.h:47
unsigned int w
width of a frame
Definition n_anim.h:61
unsigned int id
Definition n_anim.h:82
unsigned int duration
Definition n_anim.h:48
unsigned int elapsed
elapsed time since last frame change
Definition n_anim.h:90
char * name
name of the anim library
Definition n_anim.h:77
ANIM_GFX ** gfxs
Stack of gfxs.
Definition n_anim.h:71
unsigned int h
height of a frame
Definition n_anim.h:63
ANIM_FRAME * frames
each frame properties
Definition n_anim.h:54
unsigned int y
y coordinate of the animation
Definition n_anim.h:86
int x
Definition n_anim.h:46
unsigned int frame
id of the current frame
Definition n_anim.h:88
ALLEGRO_BITMAP * bmp
bitmap with a list of lil' bitmap inside
Definition n_anim.h:56
unsigned int x
x coordinate of the animation
Definition n_anim.h:84
ANIM_LIB * lib
pointer to an anim gfx library
Definition n_anim.h:93
unsigned int nb_max_gfxs
size of the stack
Definition n_anim.h:74
int delete_bmp_from_lib(ANIM_LIB *lib, unsigned int id)
delete a bitmap from the library
Definition n_anim.c:92
int add_bmp_to_lib(ANIM_LIB *lib, unsigned int pos, char *file, char *resfile)
add a bitmap to the library
Definition n_anim.c:113
ANIM_LIB * create_anim_library(const char *name, unsigned int size)
create a new animation library
Definition n_anim.c:37
int draw_anim(ANIM_DATA *data, int x, int y)
draw current animation frame
Definition n_anim.c:226
int update_anim(ANIM_DATA *data, unsigned int delta_t)
update animation frame
Definition n_anim.c:202
int destroy_anim_lib(ANIM_LIB **lib)
destroy an animation library
Definition n_anim.c:70
animation properties
Definition n_anim.h:81
struct of the properties of a frame in an animation
Definition n_anim.h:45
struct of an animation
Definition n_anim.h:52
structure of a library of gfxs
Definition n_anim.h:69
Common headers and low-level functions & define.
Generic log system.
N_STR and string function declaration.