* Draws interceptor damage according to percentage of HP's left. */
| 610 | * Draws interceptor damage according to percentage of HP's left. |
| 611 | */ |
| 612 | void DogfightState::drawCraftDamage() |
| 613 | { |
| 614 | if(_minimized) |
| 615 | { |
| 616 | return; |
| 617 | } |
| 618 | if(_craft->getDamagePercentage() != 0) |
| 619 | { |
| 620 | if(!_craftDamageAnimTimer->isRunning()) |
| 621 | { |
| 622 | _craftDamageAnimTimer->start(); |
| 623 | } |
| 624 | int damagePercentage = _craft->getDamagePercentage(); |
| 625 | int rowsToColor = (int)floor((double)_craftHeight * (double)(damagePercentage / 100.)); |
| 626 | if(rowsToColor == 0) |
| 627 | { |
| 628 | return; |
| 629 | } |
| 630 | int rowsColored = 0; |
| 631 | bool rowColored = false; |
| 632 | for(int y = 0; y < _damage->getHeight(); ++y) |
| 633 | { |
| 634 | rowColored = false; |
| 635 | for(int x = 0; x < _damage->getWidth(); ++x) |
| 636 | { |
| 637 | int pixelColor = _damage->getPixel(x, y); |
| 638 | if(pixelColor == 13 || pixelColor == 14) |
| 639 | { |
| 640 | _damage->setPixel(x, y, _currentCraftDamageColor); |
| 641 | rowColored = true; |
| 642 | } |
| 643 | if(pixelColor >= Palette::blockOffset(10) && pixelColor < Palette::blockOffset(11)) |
| 644 | { |
| 645 | _damage->setPixel(x, y, _currentCraftDamageColor); |
| 646 | rowColored = true; |
| 647 | } |
| 648 | } |
| 649 | if(rowColored) |
| 650 | { |
| 651 | ++rowsColored; |
| 652 | } |
| 653 | if(rowsColored == rowsToColor) |
| 654 | { |
| 655 | break; |
| 656 | } |
| 657 | } |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | /** |
| 662 | * Animates the window with a palette effect. |