Mercurial > MadButterfly
comparison examples/tank/tank_main.c @ 122:17e97e92b76e
Encapsulate X_MB_runtime_t and support X keyboard events.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 15 Sep 2008 20:33:06 +0800 |
parents | 5df7403b6fbc |
children | ba581d8a4b9b |
comparison
equal
deleted
inserted
replaced
121:76ba6fd61c7d | 122:17e97e92b76e |
---|---|
52 } while(0) | 52 } while(0) |
53 | 53 |
54 void | 54 void |
55 initial_tank(tank_rt_t *tank_rt, X_MB_runtime_t *mb_rt) { | 55 initial_tank(tank_rt_t *tank_rt, X_MB_runtime_t *mb_rt) { |
56 redraw_man_t *rdman; | 56 redraw_man_t *rdman; |
57 mb_tman_t *tman; | |
57 mud_t *mud; | 58 mud_t *mud; |
58 brick_t *brick; | 59 brick_t *brick; |
59 rock_t *rock; | 60 rock_t *rock; |
60 bush_t *bush; | 61 bush_t *bush; |
61 mb_word_t *word; | 62 mb_word_t *word; |
62 mb_timeval_t start, playing; | 63 mb_timeval_t start, playing; |
63 mb_timeval_t mbtv; | 64 mb_timeval_t mbtv; |
64 int i, j; | 65 int i, j; |
65 | 66 |
66 rdman = mb_rt->rdman; | 67 rdman = X_MB_rdman(mb_rt); |
67 | 68 |
68 tank_rt->mb_rt = mb_rt; | 69 tank_rt->mb_rt = mb_rt; |
69 for(i = 0; i < 12; i++) { | 70 for(i = 0; i < 12; i++) { |
70 for(j = 0; j < 16; j++) { | 71 for(j = 0; j < 16; j++) { |
71 switch(map[i][j]) { | 72 switch(map[i][j]) { |
117 word = mb_progm_next_word(tank_rt->tank1_progm, &start, &playing); | 118 word = mb_progm_next_word(tank_rt->tank1_progm, &start, &playing); |
118 | 119 |
119 mb_shift_new(0, 150, tank_rt->tank1->root_coord, word); | 120 mb_shift_new(0, 150, tank_rt->tank1->root_coord, word); |
120 mb_shift_new(0, 150, tank_rt->tank2->root_coord, word); | 121 mb_shift_new(0, 150, tank_rt->tank2->root_coord, word); |
121 | 122 |
123 tman = X_MB_tman(mb_rt); | |
122 get_now(&mbtv); | 124 get_now(&mbtv); |
123 mb_progm_start(tank_rt->tank1_progm, mb_rt->tman, &mbtv); | 125 mb_progm_start(tank_rt->tank1_progm, tman, &mbtv); |
124 } | 126 } |
125 | 127 |
126 int | 128 int |
127 main(int argc, char *const argv[]) { | 129 main(int argc, char *const argv[]) { |
128 X_MB_runtime_t rt; | 130 X_MB_runtime_t *rt; |
129 tank_rt_t tank_rt; | 131 tank_rt_t tank_rt; |
130 | 132 |
131 X_MB_init(":0.0", 800, 600, &rt); | 133 rt = X_MB_new(":0.0", 800, 600); |
132 | 134 |
133 initial_tank(&tank_rt, &rt); | 135 initial_tank(&tank_rt, rt); |
134 | 136 |
135 X_MB_handle_connection(&rt); | 137 X_MB_handle_connection(rt); |
136 | 138 |
137 X_MB_destroy(&rt); | 139 X_MB_free(rt); |
138 } | 140 } |