Mercurial > MadButterfly
comparison examples/tank/tank_main.c @ 160:147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 08 Oct 2008 03:57:56 +0800 |
parents | b90abd31a281 |
children | 530bb7728546 |
comparison
equal
deleted
inserted
replaced
159:b90abd31a281 | 160:147c93163ef0 |
---|---|
318 } | 318 } |
319 | 319 |
320 static void bullet_go_out_map_and_redraw(event_t *event, void *arg) { | 320 static void bullet_go_out_map_and_redraw(event_t *event, void *arg) { |
321 tank_t *tank = (tank_t *)arg; | 321 tank_t *tank = (tank_t *)arg; |
322 tank_bullet_t *bullet; | 322 tank_bullet_t *bullet; |
323 #if 0 | |
324 ob_factory_t *factory; | |
325 subject_t *redraw; | |
326 #endif | |
327 | 323 |
328 bullet = tank->bullet; | 324 bullet = tank->bullet; |
329 mb_progm_free(bullet->progm); | 325 mb_progm_free(bullet->progm); |
330 rdman_force_clean(bullet->rdman); | |
331 #if 0 | |
332 factory = rdman_get_ob_factory(bullet->rdman); | |
333 redraw = rdman_get_redraw_subject(bullet->rdman); | |
334 subject_remove_observer(factory, redraw, bullet->ob_redraw); | |
335 #endif | |
336 tank_bullet_free(tank->bullet); | 326 tank_bullet_free(tank->bullet); |
337 tank->bullet = NULL; | 327 tank->bullet = NULL; |
338 } | 328 } |
339 | 329 |
340 static void bullet_go_out_map(event_t *event, void *arg) { | 330 static void bullet_go_out_map(event_t *event, void *arg) { |
341 tank_t *tank = (tank_t *)arg; | 331 tank_t *tank = (tank_t *)arg; |
342 tank_bullet_t *bullet; | 332 tank_bullet_t *bullet; |
343 redraw_man_t *rdman; | 333 redraw_man_t *rdman; |
344 #if 0 | |
345 subject_t *redraw; | |
346 ob_factory_t *factory; | |
347 #endif | |
348 | 334 |
349 bullet = tank->bullet; | 335 bullet = tank->bullet; |
350 rdman = bullet->rdman; | 336 rdman = bullet->rdman; |
351 | 337 |
352 if(bullet->hit_tmr != NULL) | 338 if(bullet->hit_tmr != NULL) |
354 | 340 |
355 coord_hide(bullet->coord_pos); | 341 coord_hide(bullet->coord_pos); |
356 rdman_coord_changed(rdman, bullet->coord_pos); | 342 rdman_coord_changed(rdman, bullet->coord_pos); |
357 | 343 |
358 /*! \todo Simplify the procdure of using observer pattern. */ | 344 /*! \todo Simplify the procdure of using observer pattern. */ |
359 #if 0 | 345 |
360 factory = rdman_get_ob_factory(rdman); | |
361 redraw = rdman_get_redraw_subject(rdman); | |
362 bullet->ob_redraw = | |
363 subject_add_observer(factory, redraw, | |
364 bullet_go_out_map_and_redraw, tank); | |
365 #endif | |
366 bullet_go_out_map_and_redraw(NULL, tank); | 346 bullet_go_out_map_and_redraw(NULL, tank); |
367 } | 347 } |
368 | 348 |
369 static void bullet_bang(tank_bullet_t *bullet, int map_x, int map_y) { | 349 static void bullet_bang(tank_bullet_t *bullet, int map_x, int map_y) { |
370 } | 350 } |