comparison include/mb_types.h @ 235:65cabbdd5284

termporary revision
author Thinker K.F. Li <thinker@branda.to>
date Thu, 25 Dec 2008 18:40:27 +0800
parents 527894c2ad39
children 104d83378582
comparison
equal deleted inserted replaced
234:889cdc5f23c5 235:65cabbdd5284
104 #define GEF_DIRTY 0x1 104 #define GEF_DIRTY 0x1
105 #define GEF_HIDDEN 0x2 /*!< The geo is hidden. */ 105 #define GEF_HIDDEN 0x2 /*!< The geo is hidden. */
106 #define GEF_FREE 0x4 106 #define GEF_FREE 0x4
107 #define GEF_OV_DRAW 0x8 /*!< To flag drawed for a overlay testing. */ 107 #define GEF_OV_DRAW 0x8 /*!< To flag drawed for a overlay testing. */
108 108
109 extern int is_overlay(area_t *r1, area_t *r2); 109 extern int areas_are_overlay(area_t *r1, area_t *r2);
110 extern void area_init(area_t *area, int n_pos, co_aix pos[][2]); 110 extern void area_init(area_t *area, int n_pos, co_aix pos[][2]);
111 extern void geo_init(geo_t *g); 111 extern void geo_init(geo_t *g);
112 extern void geo_from_positions(geo_t *g, int n_pos, co_aix pos[][2]); 112 extern void geo_from_positions(geo_t *g, int n_pos, co_aix pos[][2]);
113 extern void geo_mark_overlay(geo_t *g, int n_others, geo_t **others, 113 extern void geo_mark_overlay(geo_t *g, int n_others, geo_t **others,
114 int *n_overlays, geo_t **overlays); 114 int *n_overlays, geo_t **overlays);
115 #define geo_get_shape(g) ((g)->shape) 115 #define geo_get_shape(g) ((g)->shape)
116 #define geo_get_shape_safe(g) ((g)? (g)->shape: NULL)
116 #define geo_set_shape(g, sh) do {(g)->shape = sh;} while(0) 117 #define geo_set_shape(g, sh) do {(g)->shape = sh;} while(0)
117 #define _geo_is_in(a, s, w) ((a) >= (s) && (a) < ((s) + (w))) 118 #define _geo_is_in(a, s, w) ((a) >= (s) && (a) < ((s) + (w)))
118 #define geo_pos_is_in(g, _x, _y) \ 119 #define geo_pos_is_in(g, _x, _y) \
119 (_geo_is_in(_x, (g)->cur_area->x, (g)->cur_area->w) && \ 120 (_geo_is_in(_x, (g)->cur_area->x, (g)->cur_area->w) && \
120 _geo_is_in(_y, (g)->cur_area->y, (g)->cur_area->h)) 121 _geo_is_in(_y, (g)->cur_area->y, (g)->cur_area->h))
121 #define geo_get_area(g) ((g)->cur_area) 122 #define geo_get_area(g) ((g)->cur_area)
123 #define geo_get_flags(g, mask) ((g)->flags & (mask))
124 #define geo_set_flags(g, mask) do {(g)->flags |= mask;} while(0)
125 #define geo_clear_flags(g, mask) do {(g)->flags &= ~(mask);} while(0)
122 126
123 127
124 /*! \brief A coordination system. 128 /*! \brief A coordination system.
125 * 129 *
126 * It have a transform function defined by matrix to transform 130 * It have a transform function defined by matrix to transform
215 #define coord_y(ci) ((co)->matrix[5]) 219 #define coord_y(ci) ((co)->matrix[5])
216 #define FOR_COORD_MEMBERS(coord, geo) \ 220 #define FOR_COORD_MEMBERS(coord, geo) \
217 for(geo = STAILQ_HEAD((coord)->members); \ 221 for(geo = STAILQ_HEAD((coord)->members); \
218 geo != NULL; \ 222 geo != NULL; \
219 geo = STAILQ_NEXT(geo_t, coord_next, geo)) 223 geo = STAILQ_NEXT(geo_t, coord_next, geo))
224 #define FOR_COORD_SHAPES(coord, shape) \
225 for(shape = geo_get_shape_safe(STAILQ_HEAD((coord)->members)); \
226 shape != NULL; \
227 shape = geo_get_shape_safe(STAILQ_NEXT(geo_t, coord_next, \
228 sh_get_geo(shape))))
220 #define coord_get_area(coord) ((coord)->cur_area) 229 #define coord_get_area(coord) ((coord)->cur_area)
221 230
222 /*! \brief A grahpic shape. 231 /*! \brief A grahpic shape.
223 * 232 *
224 * \dot 233 * \dot
252 #define sh_show(sh) \ 261 #define sh_show(sh) \
253 do { \ 262 do { \
254 (sh)->geo->flags &= ~GEF_HIDDEN; \ 263 (sh)->geo->flags &= ~GEF_HIDDEN; \
255 } while(0) 264 } while(0)
256 #define sh_get_geo(sh) ((sh)->geo) 265 #define sh_get_geo(sh) ((sh)->geo)
266 #define sh_get_geo_safe(sh) ((sh)? (sh)->geo: NULL)
267 #define sh_get_flags(sh, mask) geo_get_flags(sh_get_geo(sh), mask)
268 #define sh_set_flags(sh, mask) geo_set_flags(sh_get_geo(sh), mask)
269 #define sh_clear_flags(sh, mask) geo_clear_flags(sh_get_geo(sh), mask)
270 #define sh_pos_is_in(sh, x, y) geo_pos_is_in(sh_get_geo(sh), x, y)
271 #define sh_get_area(sh) geo_get_area(sh_get_geo(sh))
257 272
258 273
259 /*! \brief A sprite is a set of graphics that being an object in animation. 274 /*! \brief A sprite is a set of graphics that being an object in animation.
260 * 275 *
261 * A sprite include graphics comprise an object. For example, a tank, in 276 * A sprite include graphics comprise an object. For example, a tank, in