added start of options menu

This commit is contained in:
2025-12-08 20:29:11 +01:00
parent 7ac1207c83
commit 2abdb3b5fb
2 changed files with 57 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ public class UI {
BufferedImage heart_full, heart_half, heart_blank;
ArrayList<String> messages = new ArrayList<>();
ArrayList<Integer> messageCounter = new ArrayList<>();
public OptionState optionState;
public String currentDialogue;
public int commandNum;
public int slotCol, slotRow;
@@ -230,6 +231,10 @@ public class UI {
int frameWidth = panel.tileSize*8;
int frameHeight = panel.tileSize*10;
drawSubWindow(frameX, frameY, frameWidth, frameHeight);
switch(optionState) {
case OVERVIEW -> optionsTop(frameX, frameY);
}
}
public void drawDialogueScreen() {
drawPlayerLife();
@@ -318,4 +323,51 @@ public class UI {
messageCounter.add(0);
}
public void optionsTop(int frameX, int frameY) {
int textX, textY;
String title = "Options";
textX = getCenteredX(title);
textY = frameY + panel.tileSize;
graphics2d.drawString(title, textX, textY);
// FULLSCREEN
textX = frameX + panel.tileSize;
textY += panel.tileSize;
graphics2d.drawString("Full Screen", textX, textY);
if(commandNum == 0) graphics2d.drawString(">", textX-25, textY);
// MUSIC
textY += panel.tileSize;
graphics2d.drawString("Music", textX, textY);
if(commandNum == 1) graphics2d.drawString(">", textX-25, textY);
// SOUND EFFECTS
textY += panel.tileSize;
graphics2d.drawString("Sound Effects (SFX)", textX, textY);
if(commandNum == 2) graphics2d.drawString(">", textX-25, textY);
// CONTROL
textY += panel.tileSize;
graphics2d.drawString("Controls", textX, textY);
if(commandNum == 3) graphics2d.drawString(">", textX-25, textY);
// END GAME
textY += panel.tileSize;
graphics2d.drawString("Quit Game", textX, textY);
if(commandNum == 4) graphics2d.drawString(">", textX-25, textY);
// BACK
textY += panel.tileSize*2;
graphics2d.drawString("Back to Game", textX, textY);
if(commandNum == 5) graphics2d.drawString(">", textX-25, textY);
}
public enum OptionState {
OVERVIEW,
SCREEN,
MUSIC,
SFX,
CONTROLS,
}
}

View File

@@ -1,6 +1,7 @@
package de.miaurizius.jgame2d.core.handlers;
import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.UI;
import de.miaurizius.jgame2d.core.enums.GameState;
import java.awt.event.KeyEvent;
@@ -56,7 +57,10 @@ public class KeyHandler implements KeyListener {
case KeyEvent.VK_R -> panel.tileM.loadMap(panel.currentMap);
// GAME STATES
case KeyEvent.VK_ESCAPE -> panel.gameState = GameState.PAUSE;
case KeyEvent.VK_ESCAPE -> {
panel.gameState = GameState.PAUSE;
panel.ui.optionState = UI.OptionState.OVERVIEW;
}
case KeyEvent.VK_C -> panel.gameState = GameState.CHARACTER;
}
}