added title screen

This commit is contained in:
2025-11-28 20:37:45 +01:00
parent 88c6f4be72
commit 5fbf815595
5 changed files with 78 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ public class UI {
Graphics2D graphics2d;
Font arial_40, arial_80B;
public String currentDialogue;
public int commandNum = 0;
public UI(GamePanel panel) {
this.panel = panel;
@@ -33,6 +34,9 @@ public class UI {
case GameState.DIALOGUE:
drawDialogueScreen();
break;
case TITLE:
drawTitleScreen();
break;
}
}
@@ -61,6 +65,45 @@ public class UI {
}
}
public void drawTitleScreen() {
graphics2d.setColor(new Color(0, 0, 0));
graphics2d.fillRect(0, 0, panel.screenWidth, panel.screenHeight);
// TITLE NAME
graphics2d.setFont(graphics2d.getFont().deriveFont(Font.BOLD, 96F));
String text = "JGame2D";
int x = getCenteredX(text);
int y = panel.tileSize*3;
// SHADOW
graphics2d.setColor(Color.gray);
graphics2d.drawString(text, x+5, y+5);
// MAIN COLOR
graphics2d.setColor(Color.white);
graphics2d.drawString(text, x, y);
// MENU
graphics2d.setFont(graphics2d.getFont().deriveFont(Font.BOLD, 48F));
text = "NEW GAME";
x = getCenteredX(text);
y += panel.tileSize*4;
graphics2d.drawString(text, x, y);
if(commandNum == 0) graphics2d.drawString(">", x-panel.tileSize, y);
text = "LOAD GAME";
x = getCenteredX(text);
y += panel.tileSize;
graphics2d.drawString(text, x, y);
if(commandNum == 1) graphics2d.drawString(">", x-panel.tileSize, y);
text = "QUIT";
x = getCenteredX(text);
y += panel.tileSize;
graphics2d.drawString(text, x, y);
if(commandNum == 2) graphics2d.drawString(">", x-panel.tileSize, y);
}
public void drawSubWindow(int x, int y, int width, int height) {
graphics2d.setColor(new Color(0,0,0,210));
graphics2d.fillRoundRect(x, y, width, height, 35, 35);