v3.2.5: adjusted shielding to display in addition to HP, not on top

This commit is contained in:
Evan Debenham
2025-09-22 18:48:09 -04:00
parent 41905ba6c6
commit 5073777610
3 changed files with 37 additions and 38 deletions

View File

@@ -460,7 +460,7 @@ public class GameScene extends PixelScene {
boss = new BossHealthBar(); boss = new BossHealthBar();
boss.camera = uiCamera; boss.camera = uiCamera;
boss.setPos( (uiCamera.width - boss.width())/2, screentop + uiSize == 0 ? 26 : 7); boss.setPos( (uiCamera.width - boss.width())/2, screentop + (landscape() ? 7 : 26));
add(boss); add(boss);
resume = new ResumeIndicator(); resume = new ResumeIndicator();

View File

@@ -40,8 +40,7 @@ public class BossHealthBar extends Component {
private Image bar; private Image bar;
private Image rawShielding; private Image shieldHP;
private Image shieldedHP;
private Image hp; private Image hp;
private BitmapText hpText; private BitmapText hpText;
@@ -83,12 +82,8 @@ public class BossHealthBar extends Component {
width = bar.width; width = bar.width;
height = bar.height; height = bar.height;
rawShielding = large ? new Image(asset, 0, 55, 96, 9) : new Image(asset, 71, 5, 47, 4); shieldHP = large ? new Image(asset, 0, 55, 96, 9) : new Image(asset, 71, 5, 47, 4);
rawShielding.alpha(0.5f); add(shieldHP);
add(rawShielding);
shieldedHP = large ? new Image(asset, 0, 55, 96, 9) : new Image(asset, 71, 5, 47, 4);
add(shieldedHP);
hp = large ? new Image(asset, 0, 46, 96, 9) : new Image(asset, 71, 0, 47, 4); hp = large ? new Image(asset, 0, 46, 96, 9) : new Image(asset, 71, 0, 47, 4);
add(hp); add(hp);
@@ -142,8 +137,8 @@ public class BossHealthBar extends Component {
bar.x = x; bar.x = x;
bar.y = y; bar.y = y;
hp.x = shieldedHP.x = rawShielding.x = bar.x+(large ? 30 : 15); hp.x = shieldHP.x = bar.x+(large ? 30 : 15);
hp.y = shieldedHP.y = rawShielding.y = bar.y+(large ? 2 : 3); hp.y = shieldHP.y = bar.y+(large ? 2 : 3);
if (!large) hpText.scale.set(PixelScene.align(0.5f)); if (!large) hpText.scale.set(PixelScene.align(0.5f));
hpText.x = hp.x + (large ? (96-hpText.width())/2f : 1); hpText.x = hp.x + (large ? (96-hpText.width())/2f : 1);
@@ -187,9 +182,17 @@ public class BossHealthBar extends Component {
int shield = boss.shielding(); int shield = boss.shielding();
int max = boss.HT; int max = boss.HT;
hp.scale.x = Math.max( 0, (health-shield)/(float)max); float healthPercent = health/(float)max;
shieldedHP.scale.x = health/(float)max; float shieldPercent = shield/(float)max;
rawShielding.scale.x = shield/(float)max;
if (healthPercent + shieldPercent > 1f){
float excess = healthPercent + shieldPercent;
healthPercent /= excess;
shieldPercent /= excess;
}
hp.scale.x = healthPercent;
shieldHP.scale.x = healthPercent + shieldPercent;
if (bleeding != blood.on){ if (bleeding != blood.on){
if (bleeding) skull.tint( 0xcc0000, large ? 0.3f : 0.6f ); if (bleeding) skull.tint( 0xcc0000, large ? 0.3f : 0.6f );
@@ -204,6 +207,7 @@ public class BossHealthBar extends Component {
} else { } else {
hpText.text(health + "+" + shield + "/" + max); hpText.text(health + "+" + shield + "/" + max);
} }
hpText.measure();
hpText.x = hp.x + (large ? (96-hpText.width())/2f : 1); hpText.x = hp.x + (large ? (96-hpText.width())/2f : 1);
} }

View File

@@ -57,8 +57,7 @@ public class StatusPane extends Component {
private int lastTier = 0; private int lastTier = 0;
private Image rawShielding; private Image shieldHP;
private Image shieldedHP;
private Image hp; private Image hp;
private BitmapText hpText; private BitmapText hpText;
private Button heroInfoOnBar; private Button heroInfoOnBar;
@@ -133,14 +132,9 @@ public class StatusPane extends Component {
compass = new Compass( Statistics.amuletObtained ? Dungeon.level.entrance() : Dungeon.level.exit() ); compass = new Compass( Statistics.amuletObtained ? Dungeon.level.entrance() : Dungeon.level.exit() );
add( compass ); add( compass );
if (large) rawShielding = new Image(asset, 0, 112, 128, 9); if (large) shieldHP = new Image(asset, 0, 112, 128, 9);
else rawShielding = new Image(asset, 0, 44, 50, 4); else shieldHP = new Image(asset, 0, 44, 50, 4);
rawShielding.alpha(0.5f); add(shieldHP);
add(rawShielding);
if (large) shieldedHP = new Image(asset, 0, 112, 128, 9);
else shieldedHP = new Image(asset, 0, 44, 50, 4);
add(shieldedHP);
if (large) hp = new Image(asset, 0, 103, 128, 9); if (large) hp = new Image(asset, 0, 103, 128, 9);
else hp = new Image(asset, 0, 40, 50, 4); else hp = new Image(asset, 0, 40, 50, 4);
@@ -209,8 +203,8 @@ public class StatusPane extends Component {
exp.x = x + 30; exp.x = x + 30;
exp.y = y + 30; exp.y = y + 30;
hp.x = shieldedHP.x = rawShielding.x = x + 30; hp.x = shieldHP.x = x + 30;
hp.y = shieldedHP.y = rawShielding.y = y + 19; hp.y = shieldHP.y = y + 19;
hpText.x = hp.x + (128 - hpText.width())/2f; hpText.x = hp.x + (128 - hpText.width())/2f;
hpText.y = hp.y + 1; hpText.y = hp.y + 1;
@@ -250,12 +244,11 @@ public class StatusPane extends Component {
hpCutout.y = y; hpCutout.y = y;
} }
hp.frame(50-hpWidth, 40, 50, 4); hp.frame(50-hpWidth, 40, 50, 4);
shieldedHP.frame(50-hpWidth, 44, 50, 4); shieldHP.frame(50-hpWidth, 44, 50, 4);
rawShielding.frame(50-hpWidth, 44, 50, 4);
} }
hp.x = shieldedHP.x = rawShielding.x = hpleft; hp.x = shieldHP.x = hpleft;
hp.y = shieldedHP.y = rawShielding.y = y + 2; hp.y = shieldHP.y = y + 2;
hpText.scale.set(PixelScene.align(0.5f)); hpText.scale.set(PixelScene.align(0.5f));
hpText.x = hp.x + 1; hpText.x = hp.x + 1;
@@ -308,15 +301,18 @@ public class StatusPane extends Component {
avatar.resetColor(); avatar.resetColor();
} }
hp.scale.x = Math.max( 0, (health-shield)/(float)max); float healthPercent = health/(float)max;
shieldedHP.scale.x = health/(float)max; float shieldPercent = shield/(float)max;
if (shield > health) { if (healthPercent + shieldPercent > 1f){
rawShielding.scale.x = Math.min(1, shield / (float) max); float excess = healthPercent + shieldPercent;
} else { healthPercent /= excess;
rawShielding.scale.x = 0; shieldPercent /= excess;
} }
hp.scale.x = healthPercent;
shieldHP.scale.x = healthPercent + shieldPercent;
if (oldHP != health || oldShield != shield || oldMax != max){ if (oldHP != health || oldShield != shield || oldMax != max){
if (shield <= 0) { if (shield <= 0) {
hpText.text(health + "/" + max); hpText.text(health + "/" + max);
@@ -384,8 +380,7 @@ public class StatusPane extends Component {
heroPaneCutout.alpha(value); heroPaneCutout.alpha(value);
hpCutout.alpha(value); hpCutout.alpha(value);
avatar.alpha(value); avatar.alpha(value);
rawShielding.alpha(0.5f*value); shieldHP.alpha(value);
shieldedHP.alpha(value);
hp.alpha(value); hp.alpha(value);
hpText.alpha(0.6f*value); hpText.alpha(0.6f*value);
exp.alpha(value); exp.alpha(value);