diff --git a/src/cl/cromer/azaraka/Constantes.java b/src/cl/cromer/azaraka/Constantes.java index 96d5841..6a169dd 100644 --- a/src/cl/cromer/azaraka/Constantes.java +++ b/src/cl/cromer/azaraka/Constantes.java @@ -90,7 +90,7 @@ public interface Constantes { /** * The amount of margin to the left and right of cells */ - int LEFT_MARGIN = 50; + int LEFT_MARGIN = 40; /** * The amount of chests to draw */ @@ -126,7 +126,7 @@ public interface Constantes { /** * The default volume */ - int DEFAULT_VOLUME = 100; + int DEFAULT_VOLUME = 0; /** * Generates the scene manually instead of from the JSON file if true */ diff --git a/src/cl/cromer/azaraka/Lienzo.java b/src/cl/cromer/azaraka/Lienzo.java index 28ac438..9dc21b4 100644 --- a/src/cl/cromer/azaraka/Lienzo.java +++ b/src/cl/cromer/azaraka/Lienzo.java @@ -131,12 +131,6 @@ public class Lienzo extends Canvas implements Constantes { logger.warning(e.getMessage()); } - // Load the hearts - heartAnimation = new Animation(); - for (int i = 0; i < 5; i++) { - heartAnimation.addImage(Animation.Direction.NONE, "/img/heart/heart" + i + ".png"); - } - // Load the game over gameOverAnimation = new Animation(); gameOverAnimation.addImage(Animation.Direction.NONE, "/img/gameover/gameover.png"); @@ -247,25 +241,16 @@ public class Lienzo extends Canvas implements Constantes { gameOver = true; } int hearts = Player.MAX_HEALTH / 4; + if (heartAnimation == null) { + heartAnimation = new Animation(); + for (int i = 0; i < 5; i++) { + heartAnimation.addImage(Animation.Direction.NONE, "/img/heart/heart" + i + ".png"); + } + } for (int i = 0; i < hearts; i++) { - if (health >= 4) { - try { - heartAnimation.setCurrentFrame(4); - } - catch (AnimationException e) { - logger.warning(e.getMessage()); - } - } - else { - try { - heartAnimation.setCurrentFrame(health); - } - catch (AnimationException e) { - logger.warning(e.getMessage()); - } - } try { - int x = ((HORIZONTAL_CELLS) * CELL_PIXELS) + LEFT_MARGIN - (heartAnimation.getFrame().getWidth() * hearts) + (heartAnimation.getFrame().getWidth() * i); + heartAnimation.setCurrentFrame(Math.min(health, 4)); + int x = (HORIZONTAL_CELLS * CELL_PIXELS) + LEFT_MARGIN - (heartAnimation.getFrame().getWidth() * hearts) + (heartAnimation.getFrame().getWidth() * i); graphicBuffer.drawImage(heartAnimation.getFrame(), x, 8, null); } catch (AnimationException e) { @@ -312,7 +297,6 @@ public class Lienzo extends Canvas implements Constantes { escenario.paintComponent(graphicBuffer); } - g.drawImage(imageBuffer, 0, 0, null); if (!gameStarted) { gameStarted = true; try { @@ -326,6 +310,8 @@ public class Lienzo extends Canvas implements Constantes { logger.warning(e.getMessage()); } } + + g.drawImage(imageBuffer, 0, 0, null); } /** diff --git a/src/cl/cromer/azaraka/VentanaPrincipal.java b/src/cl/cromer/azaraka/VentanaPrincipal.java index 1e27a50..de45933 100644 --- a/src/cl/cromer/azaraka/VentanaPrincipal.java +++ b/src/cl/cromer/azaraka/VentanaPrincipal.java @@ -39,6 +39,7 @@ public class VentanaPrincipal extends JFrame implements Constantes { logger.info("Create panels"); setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH); + setSize(Toolkit.getDefaultToolkit().getScreenSize()); setTitle(TITLE); String icon = "/img/icon.png";