Welcome screen

This commit is contained in:
leahb 2025-05-18 16:09:06 +02:00
parent e085f3393f
commit 97b0a4ad00
1 changed files with 22 additions and 1 deletions

View File

@ -80,7 +80,28 @@ public class JPanelChessBoard extends JPanel {
@Override @Override
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
super.paintComponent(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) { if(pieceSelectorMode) {
g.drawImage( g.drawImage(
spriteSheet, spriteSheet,