* Move helicopter sprite. * @param sprite Helicopter sprite. * @todo Remove local magic constants and document the code. */
| 688 | * @todo Remove local magic constants and document the code. |
| 689 | */ |
| 690 | void Micropolis::doCopterSprite( |
| 691 | SimSprite *sprite) |
| 692 | { |
| 693 | static const short CDx[9] = { 0, 0, 3, 5, 3, 0, -3, -5, -3 }; |
| 694 | static const short CDy[9] = { 0, -5, -3, 0, 3, 5, 3, 0, -3 }; |
| 695 | |
| 696 | if (sprite->soundCount > 0) { |
| 697 | sprite->soundCount--; |
| 698 | } |
| 699 | |
| 700 | if (sprite->control < 0) { |
| 701 | |
| 702 | if (sprite->count > 0) { |
| 703 | sprite->count--; |
| 704 | } |
| 705 | |
| 706 | if (sprite->count == 0) { |
| 707 | |
| 708 | /* Attract copter to monster so it blows up more often */ |
| 709 | SimSprite *s = getSprite(SPRITE_MONSTER); |
| 710 | |
| 711 | if (s != NULL) { |
| 712 | sprite->destX = s->x; |
| 713 | sprite->destY = s->y; |
| 714 | } else { |
| 715 | |
| 716 | /* Attract copter to tornado so it blows up more often */ |
| 717 | s = getSprite(SPRITE_TORNADO); |
| 718 | |
| 719 | if (s != NULL) { |
| 720 | sprite->destX = s->x; |
| 721 | sprite->destY = s->y; |
| 722 | } else { |
| 723 | sprite->destX = sprite->origX; |
| 724 | sprite->destY = sprite->origY; |
| 725 | } |
| 726 | |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | if (sprite->count == 0) { /* land */ |
| 731 | getDir(sprite->x, sprite->y, sprite->origX, sprite->origY); |
| 732 | |
| 733 | if (absDist < 30) { |
| 734 | sprite->frame = 0; |
| 735 | return; |
| 736 | } |
| 737 | |
| 738 | } |
| 739 | |
| 740 | } else { |
| 741 | |
| 742 | getDir(sprite->x, sprite->y, sprite->destX, sprite->destY); |
| 743 | |
| 744 | if (absDist < 16) { |
| 745 | sprite->destX = sprite->origX; |
| 746 | sprite->destY = sprite->origY; |
| 747 | sprite->control = -1; |