Mercurial > MadButterfly
diff examples/tank/tank_main.c @ 159:b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
- Life-cycle of shapes and paints are managed by rdman.
- Add redraw_man_t::free_objs to collect objects their freeing are
postonsed.
Know Issue:
- Bullet of tank are not removed from screen when it is go out the range
of the map.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 05 Oct 2008 23:32:58 +0800 |
parents | 5cd12609a5c7 |
children | 147c93163ef0 |
line wrap: on
line diff
--- a/examples/tank/tank_main.c Fri Oct 03 10:22:08 2008 +0800 +++ b/examples/tank/tank_main.c Sun Oct 05 23:32:58 2008 +0800 @@ -320,15 +320,19 @@ static void bullet_go_out_map_and_redraw(event_t *event, void *arg) { tank_t *tank = (tank_t *)arg; tank_bullet_t *bullet; +#if 0 ob_factory_t *factory; subject_t *redraw; +#endif bullet = tank->bullet; mb_progm_free(bullet->progm); rdman_force_clean(bullet->rdman); +#if 0 factory = rdman_get_ob_factory(bullet->rdman); redraw = rdman_get_redraw_subject(bullet->rdman); subject_remove_observer(factory, redraw, bullet->ob_redraw); +#endif tank_bullet_free(tank->bullet); tank->bullet = NULL; } @@ -337,8 +341,10 @@ tank_t *tank = (tank_t *)arg; tank_bullet_t *bullet; redraw_man_t *rdman; +#if 0 subject_t *redraw; ob_factory_t *factory; +#endif bullet = tank->bullet; rdman = bullet->rdman; @@ -350,11 +356,14 @@ rdman_coord_changed(rdman, bullet->coord_pos); /*! \todo Simplify the procdure of using observer pattern. */ +#if 0 factory = rdman_get_ob_factory(rdman); redraw = rdman_get_redraw_subject(rdman); bullet->ob_redraw = subject_add_observer(factory, redraw, bullet_go_out_map_and_redraw, tank); +#endif + bullet_go_out_map_and_redraw(NULL, tank); } static void bullet_bang(tank_bullet_t *bullet, int map_x, int map_y) {