MCPcopy Create free account
hub / github.com/catabriga/graphwar / getSoldierImage

Method getSoldierImage

src/Graphwar/GraphPlane.java:439–504  ·  view source on GitHub ↗
(Soldier soldier, int player)

Source from the content-addressed store, hash-verified

437 }
438
439 private Image getSoldierImage(Soldier soldier, int player)
440 {
441 if(soldier.isExploding())
442 {
443 long timePassedAnimating = soldier.getTimeExploding();
444
445 for(int i=0; i<deathImages.length; i++)
446 {
447 if(timePassedAnimating > deathDurations[i])
448 {
449 timePassedAnimating -= deathDurations[i];
450 }
451 else
452 {
453 repaintBack = true;
454 return deathImages[i];
455 }
456 }
457
458 if(timePassedAnimating < deathFadeDuration)
459 {
460 BufferedImage fadeImage = new BufferedImage(deathImages[deathImages.length-1].getWidth(null), deathImages[deathImages.length-1].getHeight(null), BufferedImage.TYPE_4BYTE_ABGR);
461
462 Graphics2D g2d = (Graphics2D)fadeImage.getGraphics();
463
464 float alpha = 1.0f - ((float)(timePassedAnimating))/deathFadeDuration;
465
466 if(alpha < 0)
467 {
468 alpha = 0;
469 }
470
471 g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
472
473 g2d.drawImage(deathImages[deathImages.length-1], 0, 0, null);
474
475 repaintBack = true;
476
477 return fadeImage;
478 }
479
480 return null;
481 }
482 else if(soldier.isAnimating())
483 {
484 int animationNum = soldier.getAnimationNum()%playerAnimations.length;
485
486 long timePassedAnimating = soldier.getAnimationTime();
487
488 for(int i=0; i<playerAnimations[animationNum].length; i++)
489 {
490 if(timePassedAnimating > playerDurations[animationNum][i])
491 {
492 timePassedAnimating -= playerDurations[animationNum][i];
493 }
494 else
495 {
496 return animationImages[player][animationNum][i];

Callers 1

drawSoldiersMethod · 0.95

Calls 6

isAnimatingMethod · 0.80
getAnimationNumMethod · 0.80
getAnimationTimeMethod · 0.80
endAnimationMethod · 0.80
isExplodingMethod · 0.45
getTimeExplodingMethod · 0.45

Tested by

no test coverage detected