make hp bar hideable
This commit is contained in:
@@ -35,12 +35,14 @@ public class Entity {
|
|||||||
boolean attacking;
|
boolean attacking;
|
||||||
public boolean alive = true;
|
public boolean alive = true;
|
||||||
public boolean dying;
|
public boolean dying;
|
||||||
|
public boolean hpBarOn;
|
||||||
|
|
||||||
// COUNTER
|
// COUNTER
|
||||||
public int spriteCounter;
|
public int spriteCounter;
|
||||||
public int actionLock;
|
public int actionLock;
|
||||||
public int invincibleCount;
|
public int invincibleCount;
|
||||||
int dyingCount;
|
int dyingCount;
|
||||||
|
int hpBarCounter;
|
||||||
|
|
||||||
// ATTRIBUTES
|
// ATTRIBUTES
|
||||||
public EntityType type;
|
public EntityType type;
|
||||||
@@ -106,16 +108,26 @@ public class Entity {
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
// MONSTER HP-BAR
|
// MONSTER HP-BAR
|
||||||
if(this.type == EntityType.MONSTER) {
|
if(this.type == EntityType.MONSTER && hpBarOn) {
|
||||||
graphics2d.setColor(new Color(35, 35, 35));
|
graphics2d.setColor(new Color(35, 35, 35));
|
||||||
graphics2d.fillRect(screenX-1, screenY-6, panel.tileSize+2, 12);
|
graphics2d.fillRect(screenX-1, screenY-6, panel.tileSize+2, 12);
|
||||||
|
|
||||||
graphics2d.setColor(new Color(255, 0, 30));
|
graphics2d.setColor(new Color(255, 0, 30));
|
||||||
graphics2d.fillRect(screenX, screenY-5, (int) ((double) panel.tileSize/maxLife)*life, 10);
|
graphics2d.fillRect(screenX, screenY-5, (int) ((double) panel.tileSize/maxLife)*life, 10);
|
||||||
|
|
||||||
|
hpBarCounter++;
|
||||||
|
if(hpBarCounter > 600) { //bar disappears after 10 seconds
|
||||||
|
hpBarCounter = 0;
|
||||||
|
hpBarOn = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DRAW ENTITY
|
// DRAW ENTITY
|
||||||
if(invincible) graphics2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
|
if(invincible) {
|
||||||
|
hpBarOn = true;
|
||||||
|
hpBarCounter = 0;
|
||||||
|
changeOpacity(graphics2d, 0.4f);
|
||||||
|
}
|
||||||
if(dying) dyingAnimation(graphics2d);
|
if(dying) dyingAnimation(graphics2d);
|
||||||
if(type == EntityType.PLAYER) { // only modify sprite render position for player because I dont know yet how monster attack sprite are gonna look
|
if(type == EntityType.PLAYER) { // only modify sprite render position for player because I dont know yet how monster attack sprite are gonna look
|
||||||
if(attacking) graphics2d.drawImage(parseSpriteATK(),
|
if(attacking) graphics2d.drawImage(parseSpriteATK(),
|
||||||
@@ -124,7 +136,7 @@ public class Entity {
|
|||||||
else graphics2d.drawImage(parseSprite(), screenX, screenY, null);
|
else graphics2d.drawImage(parseSprite(), screenX, screenY, null);
|
||||||
} else graphics2d.drawImage(parseSprite(), screenX, screenY, null);
|
} else graphics2d.drawImage(parseSprite(), screenX, screenY, null);
|
||||||
|
|
||||||
graphics2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
|
changeOpacity(graphics2d, 1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user