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 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
28#ifndef __N_ANIM_HEADER
29#define __N_ANIM_HEADER
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35#include "n_common.h"
36#include "n_log.h"
37#include "n_str.h"
38#include "allegro5/allegro.h"
39
46typedef struct ANIM_FRAME {
47 int x,
49 unsigned int duration;
51
53typedef struct ANIM_GFX {
57 ALLEGRO_BITMAP* bmp;
58
60 unsigned int type,
67} ANIM_GFX;
68
70typedef struct ANIM_LIB {
73
75 unsigned int nb_max_gfxs;
76
78 char* name;
79} ANIM_LIB;
80
82typedef struct ANIM_DATA {
83 unsigned int id,
92
95} ANIM_DATA;
96
98ANIM_LIB* create_anim_library(const char* name, unsigned int size);
100int delete_bmp_from_lib(ANIM_LIB* lib, unsigned int id);
102int add_bmp_to_lib(ANIM_LIB* lib, unsigned int pos, char* file, char* resfile);
104int update_anim(ANIM_DATA* data, unsigned int delta_t);
106int draw_anim(ANIM_DATA* data, int x, int y);
108int destroy_anim_lib(ANIM_LIB** lib);
109
114#ifdef __cplusplus
115}
116#endif
117
118#endif // header guard
unsigned int nb_frames
nb frames in anim
Definition n_anim.h:66
unsigned int type
blit type: masked with color, blended, brut
Definition n_anim.h:60
int y
Definition n_anim.h:48
unsigned int w
width of a frame
Definition n_anim.h:62
unsigned int id
Definition n_anim.h:83
unsigned int duration
Definition n_anim.h:49
unsigned int elapsed
elapsed time since last frame change
Definition n_anim.h:91
char * name
name of the anim library
Definition n_anim.h:78
ANIM_GFX ** gfxs
Stack of gfxs.
Definition n_anim.h:72
unsigned int h
height of a frame
Definition n_anim.h:64
ANIM_FRAME * frames
each frame properties
Definition n_anim.h:55
unsigned int y
y coordinate of the animation
Definition n_anim.h:87
int x
Definition n_anim.h:47
unsigned int frame
id of the current frame
Definition n_anim.h:89
ALLEGRO_BITMAP * bmp
bitmap with a list of lil' bitmap inside
Definition n_anim.h:57
unsigned int x
x coordinate of the animation
Definition n_anim.h:85
ANIM_LIB * lib
pointer to an anim gfx library
Definition n_anim.h:94
unsigned int nb_max_gfxs
size of the stack
Definition n_anim.h:75
int delete_bmp_from_lib(ANIM_LIB *lib, unsigned int id)
delete a bitmap from the library
Definition n_anim.c:93
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:114
ANIM_LIB * create_anim_library(const char *name, unsigned int size)
create a new animation library
Definition n_anim.c:38
int draw_anim(ANIM_DATA *data, int x, int y)
draw current animation frame
Definition n_anim.c:227
int update_anim(ANIM_DATA *data, unsigned int delta_t)
update animation frame
Definition n_anim.c:203
int destroy_anim_lib(ANIM_LIB **lib)
destroy an animation library
Definition n_anim.c:71
animation properties
Definition n_anim.h:82
struct of the properties of a frame in an animation
Definition n_anim.h:46
struct of an animation
Definition n_anim.h:53
structure of a library of gfxs
Definition n_anim.h:70
Common headers and low-level functions & define.
Generic log system.
N_STR and string function declaration.