annotate include/mb_sprite.h @ 1352:9164a0782ba7

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