From c3aa7ea54005dba8ecf3d5641ef4f146102e0c12 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 28 Nov 2025 16:27:00 +0100 Subject: [PATCH] removed unnecessary code --- src/de/miaurizius/jgame2d/core/Sound.java | 3 +- src/de/miaurizius/jgame2d/core/UI.java | 15 +--------- src/de/miaurizius/jgame2d/entity/Player.java | 30 +------------------- 3 files changed, 3 insertions(+), 45 deletions(-) diff --git a/src/de/miaurizius/jgame2d/core/Sound.java b/src/de/miaurizius/jgame2d/core/Sound.java index 0199c08..79595fc 100644 --- a/src/de/miaurizius/jgame2d/core/Sound.java +++ b/src/de/miaurizius/jgame2d/core/Sound.java @@ -7,7 +7,6 @@ import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.util.logging.Level; -import java.util.logging.Logger; public class Sound { @@ -32,7 +31,7 @@ public class Sound { clip = AudioSystem.getClip(); clip.open(ais); } catch (Exception e) { - e.printStackTrace(); + Boot.logger.log(Level.SEVERE, "Could not load Sound File: " + soundURL[i], e); } } diff --git a/src/de/miaurizius/jgame2d/core/UI.java b/src/de/miaurizius/jgame2d/core/UI.java index a741f9c..5c5f750 100644 --- a/src/de/miaurizius/jgame2d/core/UI.java +++ b/src/de/miaurizius/jgame2d/core/UI.java @@ -1,21 +1,12 @@ package de.miaurizius.jgame2d.core; import java.awt.*; -import java.text.DecimalFormat; public class UI { GamePanel panel; Graphics graphics2d; Font arial_40, arial_80B; - DecimalFormat df = new DecimalFormat("#0.00"); - - public boolean messageOn = false; - public String message; - public boolean gameFinished = false; - - int msgC = 0; - double playTime; public UI(GamePanel panel) { this.panel = panel; @@ -23,11 +14,6 @@ public class UI { arial_80B = new Font("Arial", Font.BOLD, 80); } - public void showMessage(String text) { - message = text; - messageOn = true; - } - public void draw(Graphics graphics2d) { this.graphics2d = graphics2d; graphics2d.setFont(arial_40); @@ -44,6 +30,7 @@ public class UI { } public void drawPauseScreen() { + graphics2d.setFont(graphics2d.getFont().deriveFont(Font.PLAIN, 80)); String text = "PAUSED"; int y = panel.screenHeight / 2; graphics2d.drawString(text, getCenteredX(text), y); diff --git a/src/de/miaurizius/jgame2d/entity/Player.java b/src/de/miaurizius/jgame2d/entity/Player.java index 191aee9..c662bd3 100644 --- a/src/de/miaurizius/jgame2d/entity/Player.java +++ b/src/de/miaurizius/jgame2d/entity/Player.java @@ -15,7 +15,6 @@ public class Player extends Entity { public final int screenX; public final int screenY; - public int hasKey = 0; public Player(GamePanel panel, KeyHandler keyH) { this.panel = panel; @@ -97,34 +96,7 @@ public class Player extends Entity { public void pickObject(int index) { if(index == 999) return; - switch(panel.obj[index].name.toLowerCase()) { - case "key": - panel.playSE(1); - hasKey++; - panel.obj[index] = null; - panel.ui.showMessage("You got a key!"); - break; - case "door": - if(hasKey > 0) { - panel.playSE(3); - panel.obj[index] = null; - hasKey--; - panel.ui.showMessage("You opened the door!"); - } - else panel.ui.showMessage("You need a key!"); - break; - case "boots": - panel.playSE(2); - speed += 1; - panel.obj[index] = null; - panel.ui.showMessage("Speed up!"); - break; - case "chest": - panel.ui.gameFinished = true; - panel.stopMusic(); - panel.playSE(4); - break; - } + } public void draw(Graphics2D graphics2d) {