# HG changeset patch # User Thinker K.F. Li # Date 1222849805 -28800 # Node ID 5cd12609a5c759969004498b9b6c18290cfbba7f # Parent 2aad042b30a4d74ca94043a8f1bdd4cb0c125622 Make sure bullet is fired with positive shift length. diff -r 2aad042b30a4 -r 5cd12609a5c7 examples/tank/tank_main.c --- a/examples/tank/tank_main.c Wed Oct 01 14:58:27 2008 +0800 +++ b/examples/tank/tank_main.c Wed Oct 01 16:30:05 2008 +0800 @@ -424,10 +424,6 @@ dir = tank->direction; map_x = tank->map_x + map_xy_adj[dir][0]; map_y = tank->map_y + map_xy_adj[dir][1]; - tank->bullet = tank_bullet_new(rdman, map_x, map_y, dir); - bullet = tank->bullet; - bullet->tman = tman; - switch(dir) { case TD_UP: shift_len = map_y + 1; @@ -451,6 +447,13 @@ break; } + if(shift_len <= 0) + return; + + tank->bullet = tank_bullet_new(rdman, map_x, map_y, dir); + bullet = tank->bullet; + bullet->tman = tman; + progm = mb_progm_new(2, rdman); MB_TIMEVAL_SET(&start, 0, 0); MB_TIMEVAL_SET(&playing, shift_len / 4, (shift_len % 4) * 250000);