Mercurial > MadButterfly
comparison examples/tank/tank_main.c @ 120:5df7403b6fbc
Fix bug of get_now()
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 14 Sep 2008 23:05:30 +0800 |
parents | e4e47d2cdbcd |
children | 17e97e92b76e |
comparison
equal
deleted
inserted
replaced
119:257a1d314bcd | 120:5df7403b6fbc |
---|---|
1 #include <sys/time.h> | |
1 #include <mb/mb.h> | 2 #include <mb/mb.h> |
2 #include "svgs.h" | 3 #include "svgs.h" |
3 | 4 |
4 enum { MUD, ROC, BRI, BSH }; | 5 enum { MUD, ROC, BRI, BSH }; |
5 | 6 |
37 tank2_t *tank2; | 38 tank2_t *tank2; |
38 int n_enemy; | 39 int n_enemy; |
39 tank_en_t *tank_enemies[10]; | 40 tank_en_t *tank_enemies[10]; |
40 void *map[12][16]; | 41 void *map[12][16]; |
41 X_MB_runtime_t *mb_rt; | 42 X_MB_runtime_t *mb_rt; |
43 mb_progm_t *tank1_progm; | |
42 }; | 44 }; |
43 | 45 |
44 #define CHANGE_POS(g, x, y) do { \ | 46 #define CHANGE_POS(g, x, y) do { \ |
45 (g)->root_coord->matrix[0] = 1.0; \ | 47 (g)->root_coord->matrix[0] = 1.0; \ |
46 (g)->root_coord->matrix[2] = x; \ | 48 (g)->root_coord->matrix[2] = x; \ |
54 redraw_man_t *rdman; | 56 redraw_man_t *rdman; |
55 mud_t *mud; | 57 mud_t *mud; |
56 brick_t *brick; | 58 brick_t *brick; |
57 rock_t *rock; | 59 rock_t *rock; |
58 bush_t *bush; | 60 bush_t *bush; |
61 mb_word_t *word; | |
62 mb_timeval_t start, playing; | |
63 mb_timeval_t mbtv; | |
59 int i, j; | 64 int i, j; |
60 | 65 |
61 rdman = mb_rt->rdman; | 66 rdman = mb_rt->rdman; |
62 | 67 |
63 tank_rt->mb_rt = mb_rt; | 68 tank_rt->mb_rt = mb_rt; |
95 for(i = 0; i < 3; i++) { | 100 for(i = 0; i < 3; i++) { |
96 tank_rt->tank_enemies[i] = tank_en_new(rdman); | 101 tank_rt->tank_enemies[i] = tank_en_new(rdman); |
97 CHANGE_POS(tank_rt->tank_enemies[i], (2 + i * 3) * 50, 0); | 102 CHANGE_POS(tank_rt->tank_enemies[i], (2 + i * 3) * 50, 0); |
98 } | 103 } |
99 tank_rt->n_enemy = i; | 104 tank_rt->n_enemy = i; |
105 | |
106 tank_rt->tank1_progm = mb_progm_new(4, rdman); | |
107 | |
108 MB_TIMEVAL_SET(&start, 1, 0); | |
109 MB_TIMEVAL_SET(&playing, 3, 0); | |
110 word = mb_progm_next_word(tank_rt->tank1_progm, &start, &playing); | |
111 | |
112 mb_shift_new(0, -150, tank_rt->tank1->root_coord, word); | |
113 mb_shift_new(0, -150, tank_rt->tank2->root_coord, word); | |
114 | |
115 MB_TIMEVAL_SET(&start, 5, 0); | |
116 MB_TIMEVAL_SET(&playing, 3, 0); | |
117 word = mb_progm_next_word(tank_rt->tank1_progm, &start, &playing); | |
118 | |
119 mb_shift_new(0, 150, tank_rt->tank1->root_coord, word); | |
120 mb_shift_new(0, 150, tank_rt->tank2->root_coord, word); | |
121 | |
122 get_now(&mbtv); | |
123 mb_progm_start(tank_rt->tank1_progm, mb_rt->tman, &mbtv); | |
100 } | 124 } |
101 | 125 |
102 int | 126 int |
103 main(int argc, char *const argv[]) { | 127 main(int argc, char *const argv[]) { |
104 X_MB_runtime_t rt; | 128 X_MB_runtime_t rt; |