removed unnecessary code

This commit is contained in:
2025-11-28 16:27:00 +01:00
parent ff82d8f7e6
commit c3aa7ea540
3 changed files with 3 additions and 45 deletions

View File

@@ -7,7 +7,6 @@ import java.io.File;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;
public class Sound { public class Sound {
@@ -32,7 +31,7 @@ public class Sound {
clip = AudioSystem.getClip(); clip = AudioSystem.getClip();
clip.open(ais); clip.open(ais);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Boot.logger.log(Level.SEVERE, "Could not load Sound File: " + soundURL[i], e);
} }
} }

View File

@@ -1,21 +1,12 @@
package de.miaurizius.jgame2d.core; package de.miaurizius.jgame2d.core;
import java.awt.*; import java.awt.*;
import java.text.DecimalFormat;
public class UI { public class UI {
GamePanel panel; GamePanel panel;
Graphics graphics2d; Graphics graphics2d;
Font arial_40, arial_80B; 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) { public UI(GamePanel panel) {
this.panel = panel; this.panel = panel;
@@ -23,11 +14,6 @@ public class UI {
arial_80B = new Font("Arial", Font.BOLD, 80); arial_80B = new Font("Arial", Font.BOLD, 80);
} }
public void showMessage(String text) {
message = text;
messageOn = true;
}
public void draw(Graphics graphics2d) { public void draw(Graphics graphics2d) {
this.graphics2d = graphics2d; this.graphics2d = graphics2d;
graphics2d.setFont(arial_40); graphics2d.setFont(arial_40);
@@ -44,6 +30,7 @@ public class UI {
} }
public void drawPauseScreen() { public void drawPauseScreen() {
graphics2d.setFont(graphics2d.getFont().deriveFont(Font.PLAIN, 80));
String text = "PAUSED"; String text = "PAUSED";
int y = panel.screenHeight / 2; int y = panel.screenHeight / 2;
graphics2d.drawString(text, getCenteredX(text), y); graphics2d.drawString(text, getCenteredX(text), y);

View File

@@ -15,7 +15,6 @@ public class Player extends Entity {
public final int screenX; public final int screenX;
public final int screenY; public final int screenY;
public int hasKey = 0;
public Player(GamePanel panel, KeyHandler keyH) { public Player(GamePanel panel, KeyHandler keyH) {
this.panel = panel; this.panel = panel;
@@ -97,34 +96,7 @@ public class Player extends Entity {
public void pickObject(int index) { public void pickObject(int index) {
if(index == 999) return; 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) { public void draw(Graphics2D graphics2d) {