Mercurial > MadButterfly
comparison examples/tank/tank_main.c @ 157:5cd12609a5c7
Make sure bullet is fired with positive shift length.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 01 Oct 2008 16:30:05 +0800 |
parents | 2aad042b30a4 |
children | b90abd31a281 |
comparison
equal
deleted
inserted
replaced
156:2aad042b30a4 | 157:5cd12609a5c7 |
---|---|
422 tman = X_MB_tman(xmb_rt); | 422 tman = X_MB_tman(xmb_rt); |
423 | 423 |
424 dir = tank->direction; | 424 dir = tank->direction; |
425 map_x = tank->map_x + map_xy_adj[dir][0]; | 425 map_x = tank->map_x + map_xy_adj[dir][0]; |
426 map_y = tank->map_y + map_xy_adj[dir][1]; | 426 map_y = tank->map_y + map_xy_adj[dir][1]; |
427 tank->bullet = tank_bullet_new(rdman, map_x, map_y, dir); | |
428 bullet = tank->bullet; | |
429 bullet->tman = tman; | |
430 | |
431 switch(dir) { | 427 switch(dir) { |
432 case TD_UP: | 428 case TD_UP: |
433 shift_len = map_y + 1; | 429 shift_len = map_y + 1; |
434 shift_x = 0; | 430 shift_x = 0; |
435 shift_y = -shift_len * 50; | 431 shift_y = -shift_len * 50; |
448 shift_len = map_x + 1; | 444 shift_len = map_x + 1; |
449 shift_x = -shift_len * 50; | 445 shift_x = -shift_len * 50; |
450 shift_y = 0; | 446 shift_y = 0; |
451 break; | 447 break; |
452 } | 448 } |
449 | |
450 if(shift_len <= 0) | |
451 return; | |
452 | |
453 tank->bullet = tank_bullet_new(rdman, map_x, map_y, dir); | |
454 bullet = tank->bullet; | |
455 bullet->tman = tman; | |
453 | 456 |
454 progm = mb_progm_new(2, rdman); | 457 progm = mb_progm_new(2, rdman); |
455 MB_TIMEVAL_SET(&start, 0, 0); | 458 MB_TIMEVAL_SET(&start, 0, 0); |
456 MB_TIMEVAL_SET(&playing, shift_len / 4, (shift_len % 4) * 250000); | 459 MB_TIMEVAL_SET(&playing, shift_len / 4, (shift_len % 4) * 250000); |
457 word = mb_progm_next_word(progm, &start, &playing); | 460 word = mb_progm_next_word(progm, &start, &playing); |