added health bar to monster
This commit is contained in:
@@ -65,6 +65,7 @@ public class Entity {
|
||||
|
||||
if(this.type == EntityType.MONSTER && contactPlayer) {
|
||||
if(panel.player.invincible) return;
|
||||
panel.playSE(6);
|
||||
panel.player.life -= 1;
|
||||
panel.player.invincible = true;
|
||||
}
|
||||
@@ -103,12 +104,20 @@ public class Entity {
|
||||
worldY + panel.tileSize > panel.player.worldY - panel.player.screenY &&
|
||||
worldY - panel.tileSize < panel.player.worldY + panel.player.screenY
|
||||
) {
|
||||
|
||||
// MONSTER HP-BAR
|
||||
if(this.type == EntityType.MONSTER) {
|
||||
graphics2d.setColor(new Color(35, 35, 35));
|
||||
graphics2d.fillRect(screenX-1, screenY-6, panel.tileSize+2, 12);
|
||||
|
||||
graphics2d.setColor(new Color(255, 0, 30));
|
||||
graphics2d.fillRect(screenX, screenY-5, (int) ((double) panel.tileSize/maxLife)*life, 10);
|
||||
}
|
||||
|
||||
// DRAW ENTITY
|
||||
if(invincible) graphics2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
|
||||
|
||||
if(dying) dyingAnimation(graphics2d);
|
||||
|
||||
// only modify sprite render position for player because I dont know yet how monster attack sprite are gonna look
|
||||
if(type == EntityType.PLAYER) {
|
||||
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(),
|
||||
(direction == Direction.LEFT) ? screenX - panel.tileSize : screenX,
|
||||
(direction == Direction.UP) ? screenY - panel.tileSize : screenY, null);
|
||||
|
||||
Reference in New Issue
Block a user