changeset 209:6f63aa67ed83

Define types for sprite shared object.
author Thinker K.F. Li <thinker@branda.to>
date Wed, 10 Dec 2008 17:15:26 +0800
parents e01acb80f0e7
children 3fadd2f2742e
files include/mb_so.h include/mb_types.h
diffstat 2 files changed, 40 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/mb_so.h	Wed Dec 10 17:15:26 2008 +0800
@@ -0,0 +1,38 @@
+/*! \file
+ * \brief Define types for sprite shared objects.
+ *
+ * A sprite shared object includes definitions of multiple sprite factories.
+ * Sprite factories are used to create sprites for MadButterfly.
+ *
+ * \see http://en.wikipedia.org/wiki/Sprite_(computer_graphics)
+ */
+#ifndef __MB_SO_H_
+#define __MB_SO_H_
+
+/*! \brief Name of the variable that define contents in a shared object. */
+#define MB_SPRITE_SO_SYM "mb_sprite_so_def"
+
+typedef struct _mb_sprite_so mb_sprite_so_t;
+typedef struct _sprite_factory sprite_factory_t;
+
+
+/*! \brief Define content of a sprite shared object.
+ *
+ * The type of symbol with name, defined by \ref MB_SPRITE_SO_SYM, in
+ * a sprite shared object.  It define content of a sprite object, a.k.a.
+ * an array of sprite factories (\ref sprite_factory_t).
+ */
+struct _mb_sprite_so {
+    const char *soname;
+    int num_factories;
+    sprite_factory_t *factories;
+};
+
+/*! \brief Define a factory to create sprites.
+ */
+struct _sprite_factory {
+    const char *name;
+    sprite_t *(*new)(coord_t*);
+};
+
+#endif /* __MB_SO_H_ */
--- a/include/mb_types.h	Wed Dec 10 14:57:21 2008 +0800
+++ b/include/mb_types.h	Wed Dec 10 17:15:26 2008 +0800
@@ -220,8 +220,8 @@
  * sprite.
  */
 struct _mb_sprite {
-    void (*free)(struct _mb_sprite *);
-    mb_obj_t *(*get_obj_with_name)(const char *id);
+    void (*free)(mb_sprite_t *);
+    mb_obj_t *(*get_obj_with_name)(mb_sprite_t *sprite, const char *id);
 };
 
 #endif /* __MB_TYPES_H_ */