From 97b0a4ad009b2bb5de8cc5f4683eb336dda48191 Mon Sep 17 00:00:00 2001 From: leahb Date: Sun, 18 May 2025 16:09:06 +0200 Subject: [PATCH] Welcome screen --- src/windowInterface/JPanelChessBoard.java | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/windowInterface/JPanelChessBoard.java b/src/windowInterface/JPanelChessBoard.java index 78a68de..3e4aad5 100644 --- a/src/windowInterface/JPanelChessBoard.java +++ b/src/windowInterface/JPanelChessBoard.java @@ -80,7 +80,28 @@ public class JPanelChessBoard extends JPanel { @Override protected void paintComponent(Graphics g) { super.paintComponent(g); - this.setBackground(Color.black); + this.setBackground(new Color(170, 51, 106)); + + if (myGame == null) { + // Display title before game starts + g.setColor(Color.WHITE); + g.setFont(g.getFont().deriveFont(48f)); // larger font size + String title = "Chess Project"; + int stringWidth = g.getFontMetrics().stringWidth(title); + int x = (getWidth() - stringWidth) / 2; + int y = getHeight() / 2; + g.drawString(title, x, y); + + g.setFont(g.getFont().deriveFont(24f)); // Smaller font for subtitle + String subtitle = "Groupe 2A5"; + int subtitleWidth = g.getFontMetrics().stringWidth(subtitle); + int x2 = (getWidth() - subtitleWidth) / 2; + int y2 = y + 40; // 40 pixels below the title, adjust spacing if needed + g.drawString(subtitle, x2, y2); + + return; + } + if(pieceSelectorMode) { g.drawImage( spriteSheet,