added option subwindow

This commit is contained in:
2025-12-08 14:23:39 +01:00
parent fb0273afb0
commit 7ac1207c83
4 changed files with 13 additions and 7 deletions

View File

@@ -13,7 +13,7 @@ public class Boot {
window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
window.setResizable(false); window.setResizable(false);
window.setTitle("JGame2D"); window.setTitle("JGame2D");
window.setUndecorated(true); //window.setUndecorated(true);
GamePanel gamePanel = new GamePanel(); GamePanel gamePanel = new GamePanel();
window.add(gamePanel); window.add(gamePanel);

View File

@@ -223,7 +223,7 @@ public class GamePanel extends JPanel implements Runnable {
tempScreen = new BufferedImage(screenWidth, screenHeight, BufferedImage.TYPE_INT_RGB); tempScreen = new BufferedImage(screenWidth, screenHeight, BufferedImage.TYPE_INT_RGB);
fg2 = (Graphics2D) tempScreen.getGraphics(); fg2 = (Graphics2D) tempScreen.getGraphics();
setFullscreen(); //setFullscreen();
} }
public void setFullscreen() { public void setFullscreen() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

View File

@@ -221,11 +221,15 @@ public class UI {
// GAME STATES // GAME STATES
public void drawPauseScreen() { public void drawPauseScreen() {
drawPlayerLife(); graphics2d.setColor(Color.white);
graphics2d.setFont(graphics2d.getFont().deriveFont(Font.PLAIN, 80)); graphics2d.setFont(graphics2d.getFont().deriveFont(32F));
String text = "PAUSED";
int y = panel.screenHeight / 2; // SUB WINDOW
graphics2d.drawString(text, getCenteredX(text), y); int frameX = panel.tileSize*6;
int frameY = panel.tileSize;
int frameWidth = panel.tileSize*8;
int frameHeight = panel.tileSize*10;
drawSubWindow(frameX, frameY, frameWidth, frameHeight);
} }
public void drawDialogueScreen() { public void drawDialogueScreen() {
drawPlayerLife(); drawPlayerLife();

View File

@@ -61,6 +61,8 @@ public class KeyHandler implements KeyListener {
} }
} }
public void handlePause(int code) { public void handlePause(int code) {
if(code == KeyEvent.VK_SPACE) spacePressed = true;
// EXIT STATE // EXIT STATE
if(code == KeyEvent.VK_ESCAPE) panel.gameState = GameState.PLAY; if(code == KeyEvent.VK_ESCAPE) panel.gameState = GameState.PLAY;
} }