comparison 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
comparison
equal deleted inserted replaced
158:c1cdd3fcd28f 159:b90abd31a281
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
323 ob_factory_t *factory; 324 ob_factory_t *factory;
324 subject_t *redraw; 325 subject_t *redraw;
326 #endif
325 327
326 bullet = tank->bullet; 328 bullet = tank->bullet;
327 mb_progm_free(bullet->progm); 329 mb_progm_free(bullet->progm);
328 rdman_force_clean(bullet->rdman); 330 rdman_force_clean(bullet->rdman);
331 #if 0
329 factory = rdman_get_ob_factory(bullet->rdman); 332 factory = rdman_get_ob_factory(bullet->rdman);
330 redraw = rdman_get_redraw_subject(bullet->rdman); 333 redraw = rdman_get_redraw_subject(bullet->rdman);
331 subject_remove_observer(factory, redraw, bullet->ob_redraw); 334 subject_remove_observer(factory, redraw, bullet->ob_redraw);
335 #endif
332 tank_bullet_free(tank->bullet); 336 tank_bullet_free(tank->bullet);
333 tank->bullet = NULL; 337 tank->bullet = NULL;
334 } 338 }
335 339
336 static void bullet_go_out_map(event_t *event, void *arg) { 340 static void bullet_go_out_map(event_t *event, void *arg) {
337 tank_t *tank = (tank_t *)arg; 341 tank_t *tank = (tank_t *)arg;
338 tank_bullet_t *bullet; 342 tank_bullet_t *bullet;
339 redraw_man_t *rdman; 343 redraw_man_t *rdman;
344 #if 0
340 subject_t *redraw; 345 subject_t *redraw;
341 ob_factory_t *factory; 346 ob_factory_t *factory;
347 #endif
342 348
343 bullet = tank->bullet; 349 bullet = tank->bullet;
344 rdman = bullet->rdman; 350 rdman = bullet->rdman;
345 351
346 if(bullet->hit_tmr != NULL) 352 if(bullet->hit_tmr != NULL)
348 354
349 coord_hide(bullet->coord_pos); 355 coord_hide(bullet->coord_pos);
350 rdman_coord_changed(rdman, bullet->coord_pos); 356 rdman_coord_changed(rdman, bullet->coord_pos);
351 357
352 /*! \todo Simplify the procdure of using observer pattern. */ 358 /*! \todo Simplify the procdure of using observer pattern. */
359 #if 0
353 factory = rdman_get_ob_factory(rdman); 360 factory = rdman_get_ob_factory(rdman);
354 redraw = rdman_get_redraw_subject(rdman); 361 redraw = rdman_get_redraw_subject(rdman);
355 bullet->ob_redraw = 362 bullet->ob_redraw =
356 subject_add_observer(factory, redraw, 363 subject_add_observer(factory, redraw,
357 bullet_go_out_map_and_redraw, tank); 364 bullet_go_out_map_and_redraw, tank);
365 #endif
366 bullet_go_out_map_and_redraw(NULL, tank);
358 } 367 }
359 368
360 static void bullet_bang(tank_bullet_t *bullet, int map_x, int map_y) { 369 static void bullet_bang(tank_bullet_t *bullet, int map_x, int map_y) {
361 } 370 }
362 371