annotate examples/tank/tank.h @ 1214:e55499f7505a

Fix the issues with multiple framelines - For multiple framelines, user move mouse from one frameline to another, the frame is not showed correctly. - Old implementation always draw normal frame on the frameline where mouse just leaving. - It is fixed by detecting leave-notify event and removing hover mark. - When user active a frame on a frameline that is not what old active frame is at, the old active frame is not deactivated. - It is fixed by calling frameline.deactive() of a frameline when a frame is activated on another frameline.
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 05 Jan 2011 17:56:14 +0800
parents fb79175e6cc3
children
rev   line source
1100
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
1 #ifndef __TANK_H_
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
2 #define __TANK_H_
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
3
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
4 #include <mb.h>
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
5 #include "svgs.h"
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
6
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
7 /*! \ingroup tank
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
8 * @{
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
9 */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
10 /*! \brief Tile types in a map. */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
11 enum { MUD, ROC, BRI, BSH };
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
12
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
13 /*! \brief Map of the game. */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
14 extern char map[12][16];
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
15
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
16 #define MAP_W 16
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
17 #define MAP_H 12
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
18 /* @} */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
19
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
20 /*! \defgroup bullet_elf Bullet Elf
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
21 * \ingroup tank
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
22 * @{
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
23 */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
24 /*! \brief Information about bullet elf
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
25 */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
26 struct _tank_bullet {
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
27 redraw_man_t *rdman;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
28 coord_t *coord_pos;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
29 coord_t *coord_rot;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
30 bullet_t *bullet_obj;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
31 int start_map_x, start_map_y;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
32 int direction;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
33 mb_progm_t *progm;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
34 mb_timeval_t start_time;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
35 observer_t *observer_redraw;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
36 int hit_tmr;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
37 mb_timer_man_t *timer_man;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
38 };
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
39 typedef struct _tank_bullet tank_bullet_t;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
40 /*! \brief The direction a bullet is going.
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
41 */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
42 enum { BU_UP = 0, BU_RIGHT, BU_DOWN, BU_LEFT };
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
43 /* @} */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
44
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
45 /*! \defgroup tank_elf Tank Elf
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
46 * \brief Tank elf module provides control functions of tanks in game.
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
47 * \ingroup tank
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
48 * @{
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
49 */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
50 /*! \brief Information about a tank elf. */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
51 struct _tank {
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
52 coord_t *coord_pos; /*!< \brief coordinate for position */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
53 coord_t *coord_rot; /*!< \brief coordinate for rotation */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
54 coord_t *coord_center;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
55 int map_x, map_y;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
56 int direction;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
57 mb_progm_t *progm;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
58 tank_bullet_t *bullet;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
59 struct _tank_rt *tank_rt; /*!< \brief for bullet to check
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
60 * hitting on tanks.
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
61 */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
62 };
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
63 typedef struct _tank tank_t;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
64 enum { TD_UP = 0, TD_RIGHT, TD_DOWN, TD_LEFT };
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
65
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
66 /* @} */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
67
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
68 /*
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
69 * \ingroup tank
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
70 * @{
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
71 */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
72 typedef struct _tank_rt tank_rt_t;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
73
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
74 /*! \brief Runtime information for tank, this game/example.
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
75 */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
76 struct _tank_rt {
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
77 tank_t *tank1;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
78 tank1_t *tank1_o;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
79 tank_t *tank2;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
80 tank2_t *tank2_o;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
81 int n_enemy;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
82 tank_t *tank_enemies[10];
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
83 tank_en_t *tank_enemies_o[10];
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
84 tank_t *tanks[12];
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
85 int n_tanks;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
86 void *map[12][16];
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
87 mb_rt_t *mb_rt;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
88 observer_t *kb_observer;
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
89 };
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
90
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
91 extern void tank_move(tank_t *tank, int direction, tank_rt_t *tank_rt);
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
92 extern void tank_fire_bullet(tank_rt_t *tank_rt, tank_t *tank);
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
93
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
94 /* From enemy.c */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
95 extern void init_enemies(tank_rt_t *tank_rt);
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
96
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
97 /* @} */
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
98
fb79175e6cc3 Add AI for enemy tanks
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
99 #endif /* __TANK_H_ */