Mercurial > MadButterfly
comparison include/mb_sprite.h @ 1051:8679b03f72e8
Move declaration about sprite to a separated header file.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 24 Nov 2010 14:19:00 +0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1050:83f39fdfbdaa | 1051:8679b03f72e8 |
---|---|
1 #ifndef __MB_SPRITE_H_ | |
2 #define __MB_SPRITE_H_ | |
3 | |
4 #include "mb_types.h" | |
5 #include "mb_redraw_man.h" | |
6 | |
7 /*! \defgroup mb_sprite Implement sprites for animation. | |
8 * @{ | |
9 */ | |
10 /*! \brief A sprite is a set of graphics that being an object in animation. | |
11 * | |
12 * A sprite include graphics comprise an object. For example, a tank, in | |
13 * example tank, is comprised a set of graphics that is represented as a | |
14 * sprite. | |
15 */ | |
16 struct _mb_sprite { | |
17 void (*free)(mb_sprite_t *); | |
18 mb_obj_t *(*get_obj_with_name)(mb_sprite_t *sprite, const char *id); | |
19 /*! Return non-zero for error. */ | |
20 int (*goto_scene)(mb_sprite_t *sprite, int scene_no); | |
21 }; | |
22 | |
23 #define MB_SPRITE_FREE(sprite) ((mb_sprite_t *)(sprite))->free(sprite) | |
24 #define MB_SPRITE_GET_OBJ(sprite, name) \ | |
25 ((mb_sprite_t *)(sprite))->get_obj_with_name((mb_sprite_t *)(sprite), \ | |
26 (name)) | |
27 #define MB_SPRITE_GOTO_SCENE(sprite, scene_no) \ | |
28 ((mb_sprite_t *)(sprite))->goto_scene((mb_sprite_t *)(sprite), scene_no) | |
29 | |
30 | |
31 /*! \brief Load sprite dymanicly from the shared object module. | |
32 * | |
33 * The search path can be changed by sprite_set_search_path. The name | |
34 * can have a relative path in the front of it. | |
35 * This function will search the object in the current working directory | |
36 * and then search the system search path. | |
37 */ | |
38 extern mb_sprite_t *sprite_load(const char *name, redraw_man_t *rdman, | |
39 coord_t *root); | |
40 | |
41 /*! \brief Set the search path of dymanic object loading. | |
42 * | |
43 */ | |
44 extern void sprite_set_search_path(const char *path); | |
45 | |
46 /*! \defgroup mb_sprite_lsym Sprite with linear symbol table. | |
47 * @{ | |
48 */ | |
49 struct _mb_sprite_lsym_entry { | |
50 const char *sym; | |
51 const int offset; | |
52 }; | |
53 typedef struct _mb_sprite_lsym_entry mb_sprite_lsym_entry_t; | |
54 | |
55 /*! \brief A sub-type of mb_sprite_t with linear symbol table. | |
56 * | |
57 * This type of sprite search symbols with linear/or binary searching. | |
58 */ | |
59 struct _mb_sprite_lsym { | |
60 mb_sprite_t sprite; | |
61 int num_entries; | |
62 mb_sprite_lsym_entry_t *entries; | |
63 }; | |
64 typedef struct _mb_sprite_lsym mb_sprite_lsym_t; | |
65 /* @} */ | |
66 /* @} */ | |
67 | |
68 #endif /* __MB_SPRITE_H_ */ | |
69 |