diff --git a/src/de/miaurizius/jgame2d/core/handlers/Sound.java b/src/de/miaurizius/jgame2d/core/handlers/Sound.java index 4eb38e4..024b929 100644 --- a/src/de/miaurizius/jgame2d/core/handlers/Sound.java +++ b/src/de/miaurizius/jgame2d/core/handlers/Sound.java @@ -24,6 +24,7 @@ public class Sound { soundURL[4] = new File("assets/sounds/fanfare.wav").toURI().toURL(); soundURL[5] = new File("assets/sounds/hitmonster.wav").toURI().toURL(); soundURL[6] = new File("assets/sounds/receivedamage.wav").toURI().toURL(); + soundURL[7] = new File("assets/sounds/blocked.wav").toURI().toURL(); } catch(MalformedURLException e) { Boot.logger.log(Level.SEVERE, e.getMessage()); } diff --git a/src/de/miaurizius/jgame2d/entity/Entity.java b/src/de/miaurizius/jgame2d/entity/Entity.java index 79e019b..588983f 100644 --- a/src/de/miaurizius/jgame2d/entity/Entity.java +++ b/src/de/miaurizius/jgame2d/entity/Entity.java @@ -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); diff --git a/src/de/miaurizius/jgame2d/entity/Player.java b/src/de/miaurizius/jgame2d/entity/Player.java index d9a7601..12d1c1c 100644 --- a/src/de/miaurizius/jgame2d/entity/Player.java +++ b/src/de/miaurizius/jgame2d/entity/Player.java @@ -160,7 +160,10 @@ public class Player extends Entity { public void interactNPC(int index) { if(index == 999) { - if(panel.keyH.spacePressed) attacking = true; + if(panel.keyH.spacePressed) { + attacking = true; + //panel.playSE(7); //remains disabled because game does weird things while playing the sound + } return; } //if(!panel.keyH.spacePressed) return; //Only uncomment if text should only appear if player hits space