Nilorea Library

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Macros
n_anim.h
Go to the documentation of this file.
1
15 #ifndef __2D_ANIM__
16
17 #define __2D_ANIM__
18
19 #ifdef __cplusplus
20 extern "C"
21 {
22 #endif
23
28 #define NORMAL_SPRITE 0
29
30
31
36 #define MASKED_SPRITE 1
37
38
39
44 #define TRANS_SPRITE 2
45
46
47
50 typedef struct SPRITE
51 {
53 BITMAP **spr;
54
55 int
56 w,
58 h,
60 x,
62 y,
64 type,
66 delay,
68 current,
70 max,
72 alive,
74 namelenght;
75
77 GLuint *handles;
78
80 char *name;
81
82 } SPRITE;
83
84
85
87 typedef struct ANIM
88 {
90 SPRITE **data;
91
92
93 int
94 nbsprite,
96 hightest,
98 max,
100 namelenght;
101
103 char *name;
104
105 } ANIM;
106
108 typedef struct ISO_ANIM
109 {
110
111 /* there are the whole move processing pictures */
112 /* SPRITE *data[ STOP || WALK || RUN || FLY || SWIM || DEATH ][ NORTH || SOUTH || EAST || WEST ] [ DIRECTION ]*/
113 /* You can combine direction N with O and E , S with O and E, but not N with S nor E with W */
114 /* You can't combine any action. Just try to imagine someone running while swimming, heh, funny ! */
115
117 SPRITE ****data;
118
119 int
120 nbsprite,
122 hightest,
124 max,
126 namelenght;
127
129 char *name;
130
131 } ISO_ANIM;
132
133
134 /*******************************************************************************
135 SPRITE STRUCTURE MANAGEMENT
136 *******************************************************************************/
137
138
139 /*
140 * init a SPRITE
141 */
142
143 int init_sprite( SPRITE **spr , char *name , int w , int h , int x , int y ,
144 int type , int delay , int max );
145
146
147
148 /*
149 * Add if possible a bimtap to a sprite
150 */
151
152 int add_bmp_to_spr( BITMAP *bmp , SPRITE *spr );
153
154
155
156 /*
157 * read a sprite in an opening file
158 */
159
160 int read_sprite_in_file( PACKFILE *file , SPRITE **spr );
161
162
163
164 /*
165 * write a sprite in an opening file
166 */
167
168 int write_sprite_in_file( PACKFILE *file , SPRITE *spr );
169
170
171
172 /*
173 * Read a Sprite from the old SprEditor format
174 */
175
176 SPRITE *GetOldSprite( char *bmpfilename , char *txtfilename , char *name );
177
178
179
180 /*
181 * draw a sprite at the right position
182 */
183
184 int blit_sprite( SPRITE *sprite , int x , int y , int frame , BITMAP *bmp );
185
186
187
188 /*
189 * free a sprite from memory
190 */
191
192 int free_sprite( SPRITE **spr );
193
194
195
196 /*******************************************************************************
197 ANIM STRUCTURE MANAGEMENT
198 *******************************************************************************/
199
200
201
202 /*
203 * Create an empty libray of anims
204 */
205
206 int create_animlib( ANIM **lib , char *name , int max );
207
208
209 /*
210 * load an anim file from disk , return FALSE if : not existing and
211 * error creating : existing and error reallocating if not enought big)
212 */
213
214 int load_animlib( PACKFILE *file , ANIM **lib );
215
216
217
218 /*
219 * save an anim library to disk ( cropping the various arrays )
220 */
221
222 int save_animlib( PACKFILE *file , ANIM *lib );
223
224
225
226 /*
227 * add sprite to lib
228 */
229
230 int add_sprite_to_lib( SPRITE *spr , ANIM *lib );
231
232
233 /*
234 * remove sprite from library
235 */
236
237 int remove_sprite_from_lib( ANIM *lib , int id );
238
239 /*
240 * Resize a library for nbelement
241 */
242
243 int Resize_anim_lib( ANIM *lib , int nb );
244
245
246
247 /*
248 * free an anim library
249 */
250
251 int free_anim( ANIM *lib );
252
253
254 /*
255 * draw a sprite in lib
256 */
257
258 int blit_anim( ANIM *lib , int id , int x , int y , int frame , BITMAP *bmp );
259
260
261
262 /*
263 * check if a sprite already exist in a lib
264 */
265
266 int exist_sprite( ANIM *lib , char *name );
267
268
269
270 /*****************************************************************************
271 * ISO_ANIM STRUCTURE MANAGEMENT *
272 *****************************************************************************/
273
274 /*
275 * Create an empty libray of anims
276 */
277
278 int create_iso_anim_lib( ISO_ANIM **lib , char *name , int max );
279
280
281 /*
282 * load an anim file from disk , return FALSE if : not existing and
283 * error creating : existing and error reallocating if not enought big)
284 */
285
286 int load_iso_anim_lib( PACKFILE *file , ISO_ANIM **lib );
287
288
289
290 /*
291 * save an anim library to disk ( cropping the various arrays )
292 */
293
294 int save_iso_anim_lib( PACKFILE *file , ISO_ANIM *lib );
295
296
297
298 /*
299 * add sprite to lib
300 */
301
302 int add_to_iso_anim_lib( SPRITE *spr , ISO_ANIM *lib );
303
304
305 /*
306 * remove sprite from library
307 */
308
309 int rem_from_iso_anim_lib( ISO_ANIM *lib , int id );
310
311 /*
312 * Resize a library for nbelement
313 */
314
315 int crop_iso_anim_lib( ISO_ANIM *lib , int nb );
316
317
318
319 /*
320 * free an anim library
321 */
322
323 int free_iso_anim_lib( ISO_ANIM *lib );
324
325
326 /*
327 * draw a sprite in lib
328 */
329
330 int blit_iso_anim( ISO_ANIM *lib , int id , int x , int y , int frame , BITMAP *bmp );
331
332
333
334 /*
335 * check if a sprite already exist in a lib
336 */
337
338 int exist_in_iso_lib( ISO_ANIM *lib , char *name );
339
340
341 #ifdef __cplusplus
342 }
343 #endif
344
345
346
347 #endif /*#ifndef __2D_ANIM__*/