1100
|
1 #ifndef __TANK_H_
|
|
2 #define __TANK_H_
|
|
3
|
|
4 #include <mb.h>
|
|
5 #include "svgs.h"
|
|
6
|
|
7 /*! \ingroup tank
|
|
8 * @{
|
|
9 */
|
|
10 /*! \brief Tile types in a map. */
|
|
11 enum { MUD, ROC, BRI, BSH };
|
|
12
|
|
13 /*! \brief Map of the game. */
|
|
14 extern char map[12][16];
|
|
15
|
|
16 #define MAP_W 16
|
|
17 #define MAP_H 12
|
|
18 /* @} */
|
|
19
|
|
20 /*! \defgroup bullet_elf Bullet Elf
|
|
21 * \ingroup tank
|
|
22 * @{
|
|
23 */
|
|
24 /*! \brief Information about bullet elf
|
|
25 */
|
|
26 struct _tank_bullet {
|
|
27 redraw_man_t *rdman;
|
|
28 coord_t *coord_pos;
|
|
29 coord_t *coord_rot;
|
|
30 bullet_t *bullet_obj;
|
|
31 int start_map_x, start_map_y;
|
|
32 int direction;
|
|
33 mb_progm_t *progm;
|
|
34 mb_timeval_t start_time;
|
|
35 observer_t *observer_redraw;
|
|
36 int hit_tmr;
|
|
37 mb_timer_man_t *timer_man;
|
|
38 };
|
|
39 typedef struct _tank_bullet tank_bullet_t;
|
|
40 /*! \brief The direction a bullet is going.
|
|
41 */
|
|
42 enum { BU_UP = 0, BU_RIGHT, BU_DOWN, BU_LEFT };
|
|
43 /* @} */
|
|
44
|
|
45 /*! \defgroup tank_elf Tank Elf
|
|
46 * \brief Tank elf module provides control functions of tanks in game.
|
|
47 * \ingroup tank
|
|
48 * @{
|
|
49 */
|
|
50 /*! \brief Information about a tank elf. */
|
|
51 struct _tank {
|
|
52 coord_t *coord_pos; /*!< \brief coordinate for position */
|
|
53 coord_t *coord_rot; /*!< \brief coordinate for rotation */
|
|
54 coord_t *coord_center;
|
|
55 int map_x, map_y;
|
|
56 int direction;
|
|
57 mb_progm_t *progm;
|
|
58 tank_bullet_t *bullet;
|
|
59 struct _tank_rt *tank_rt; /*!< \brief for bullet to check
|
|
60 * hitting on tanks.
|
|
61 */
|
|
62 };
|
|
63 typedef struct _tank tank_t;
|
|
64 enum { TD_UP = 0, TD_RIGHT, TD_DOWN, TD_LEFT };
|
|
65
|
|
66 /* @} */
|
|
67
|
|
68 /*
|
|
69 * \ingroup tank
|
|
70 * @{
|
|
71 */
|
|
72 typedef struct _tank_rt tank_rt_t;
|
|
73
|
|
74 /*! \brief Runtime information for tank, this game/example.
|
|
75 */
|
|
76 struct _tank_rt {
|
|
77 tank_t *tank1;
|
|
78 tank1_t *tank1_o;
|
|
79 tank_t *tank2;
|
|
80 tank2_t *tank2_o;
|
|
81 int n_enemy;
|
|
82 tank_t *tank_enemies[10];
|
|
83 tank_en_t *tank_enemies_o[10];
|
|
84 tank_t *tanks[12];
|
|
85 int n_tanks;
|
|
86 void *map[12][16];
|
|
87 mb_rt_t *mb_rt;
|
|
88 observer_t *kb_observer;
|
|
89 };
|
|
90
|
|
91 extern void tank_move(tank_t *tank, int direction, tank_rt_t *tank_rt);
|
|
92 extern void tank_fire_bullet(tank_rt_t *tank_rt, tank_t *tank);
|
|
93
|
|
94 /* From enemy.c */
|
|
95 extern void init_enemies(tank_rt_t *tank_rt);
|
|
96
|
|
97 /* @} */
|
|
98
|
|
99 #endif /* __TANK_H_ */
|