changeset 190:0a924eb9ccab

Group and document code of example tank.
author Thinker K.F. Li <thinker@branda.to>
date Tue, 18 Nov 2008 13:25:52 +0800
parents 257af0ed5852
children 18f8c3126cdb
files examples/tank/tank_main.c
diffstat 1 files changed, 39 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/examples/tank/tank_main.c	Tue Nov 18 09:04:40 2008 +0800
+++ b/examples/tank/tank_main.c	Tue Nov 18 13:25:52 2008 +0800
@@ -5,8 +5,13 @@
 #include <mb_tools.h>
 #include "svgs.h"
 
+/*! \defgroup tank Example Tank
+ * @{
+ */
+/*! \brief Tile types in a map. */
 enum { MUD, ROC, BRI, BSH };
 
+/*! \brief Map of the game. */
 static char map[12][16] = {
     { MUD, MUD, MUD, MUD, MUD, MUD, MUD, MUD,
       MUD, MUD, MUD, MUD, MUD, MUD, MUD, MUD},
@@ -36,11 +41,14 @@
 
 #define MAP_W 16
 #define MAP_H 12
+/* @} */
 
-/*! \defgroup tank_elf Tank Elf
- * \brief Tank elf module provides control functions of tanks in game.
+/*! \defgroup bullet_elf Bullet Elf
+ * \ingroup tank
  * @{
  */
+/*! \brief Information about bullet elf
+ */
 struct _tank_bullet {
     redraw_man_t *rdman;
     coord_t *coord_pos;
@@ -55,8 +63,17 @@
     mb_tman_t *tman;
 };
 typedef struct _tank_bullet tank_bullet_t;
+/*! \brief The direction a bullet is going.
+ */
 enum { BU_UP = 0, BU_RIGHT, BU_DOWN, BU_LEFT };
+/* @} */
 
+/*! \defgroup tank_elf Tank Elf
+ * \brief Tank elf module provides control functions of tanks in game.
+ * \ingroup tank
+ * @{
+ */
+/*! \brief Information about a tank elf. */
 struct _tank {
     coord_t *coord_pos;		/*!< \brief coordinate for position */
     coord_t *coord_rot;		/*!< \brief coordinate for rotation */
@@ -76,6 +93,8 @@
 
 typedef struct _tank_rt tank_rt_t;
 
+/*! \brief Runtime information for tank, this game/example.
+ */
 struct _tank_rt {
     tank_t *tank1;
     tank1_t *tank1_o;
@@ -256,6 +275,9 @@
 
 /* @} */
 
+/*! \ingroup bullet_elf
+ * @{
+ */
 /*! \brief Make coord objects for bullet elfs. */
 static void make_bullet_elf_coords(redraw_man_t *rdman, coord_t **coord_pos,
 				   coord_t **coord_rot,
@@ -376,6 +398,7 @@
     mb_progm_start(progm, tman, &now);
 }
 
+/*! \brief To check if a bullet hits walls or tanks. */
 static void bullet_hit_chk(const mb_timeval_t *tmo,
 			   const mb_timeval_t *now,
 			   void *arg) {
@@ -455,6 +478,7 @@
 				      bullet_hit_chk, arg);
 }
 
+/*! \brief To fire a bullet for a tank. */
 static void tank_fire_bullet(tank_rt_t *tank_rt, tank_t *tank) {
     X_MB_runtime_t *xmb_rt;
     redraw_man_t *rdman;
@@ -534,6 +558,11 @@
     bullet->hit_tmr = mb_tman_timeout(tman, &next, bullet_hit_chk, tank);
 }
 
+/* @} */
+
+/*! \ingroup tank
+ * @{
+ */
 #define CHANGE_POS(g, x, y) do {			\
 	(g)->root_coord->matrix[0] = 1.0;		\
 	(g)->root_coord->matrix[2] = x;			\
@@ -597,7 +626,12 @@
 	subject_add_observer(factory, kbevents, keyboard_handler, tank_rt);
 }
 
-/*! \brief Make coord objects for elfs (tanks). */
+/*! \brief Make coord objects to decorate elfs (tanks).
+ *
+ * These coords are used to shift (move) and rotate decorated graphic.
+ * The coords can easy work of programmer to manipulate geometry of
+ * decorated graphic.
+ */
 static void make_elf_coords(redraw_man_t *rdman, coord_t **coord_pos,
 			    coord_t **coord_rot, coord_t **coord_center) {
     coord_t *coord_back;
@@ -702,3 +736,5 @@
 
     X_MB_free(rt);
 }
+
+/* @} */