feat: improve texture & design

This commit is contained in:
Martin Prokoph
2025-06-28 21:51:45 +02:00
parent a906bc5381
commit 4c0f8d1c02
5 changed files with 32 additions and 10 deletions

View File

@@ -52,8 +52,10 @@ public class Tetris {
};
timer.scheduleAtFixedRate(gravityTask, 1, Settings.difficulty.getTimerPeriod());
}
public static void stopGame() {
gravityTask.cancel();
timer.purge();
if (ui.getMenuPanel() instanceof ScoreMenu) ((ScoreMenu) Tetris.ui.getMenuPanel()).gameOver();
ui.transferFocus();
}

View File

@@ -2,6 +2,7 @@ package eu.midnightdust.yaytris.ui;
import eu.midnightdust.yaytris.Tetris;
import eu.midnightdust.yaytris.game.Space;
import eu.midnightdust.yaytris.util.CatppuccinColor;
import javax.imageio.ImageIO;
import javax.swing.*;
@@ -25,7 +26,7 @@ public class TetrisUI extends JFrame implements KeyListener {
this.setTitle("Tetris");
this.setSize((int) (400 * guiScale), (int) (300 * guiScale));
this.setResizable(false);
this.getContentPane().setBackground(Color.DARK_GRAY);
this.getContentPane().setBackground(CatppuccinColor.MANTLE.getColor());
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setWindowPosition(this, 0);
@@ -43,7 +44,7 @@ public class TetrisUI extends JFrame implements KeyListener {
gamePanel = new GameCanvas(this);
gamePanel.setBackground(Color.BLACK);
gamePanel.setBorder(new LineBorder(Color.GRAY, scale(2)));
gamePanel.setBorder(new LineBorder(CatppuccinColor.SURFACE0.getColor(), scale(2)));
this.add(gamePanel);
rescale();
@@ -91,8 +92,8 @@ public class TetrisUI extends JFrame implements KeyListener {
Tetris.resetSpace();
rescale();
menuPanel = new MainMenu(scale(170), scale(40), scale(220), scale(226), this);
menuPanel.setBackground(Color.DARK_GRAY);
menuPanel.setBorder(new LineBorder(Color.GRAY, scale(2)));
menuPanel.setBackground(CatppuccinColor.BASE.getColor());
menuPanel.setBorder(new LineBorder(CatppuccinColor.SURFACE0.getColor(), scale(2)));
this.add(menuPanel);
this.repaint();
}
@@ -100,8 +101,8 @@ public class TetrisUI extends JFrame implements KeyListener {
public void openSettings(ActionEvent actionEvent) {
if (this.menuPanel != null) this.remove(menuPanel);
menuPanel = new SettingsMenu(scale(170), scale(40), scale(220), scale(226), this);
menuPanel.setBackground(Color.DARK_GRAY);
menuPanel.setBorder(new LineBorder(Color.GRAY, scale(2)));
menuPanel.setBackground(CatppuccinColor.BASE.getColor());
menuPanel.setBorder(new LineBorder(CatppuccinColor.SURFACE0.getColor(), scale(2)));
this.add(menuPanel);
this.repaint();
}
@@ -109,8 +110,8 @@ public class TetrisUI extends JFrame implements KeyListener {
public void openScoreMenu(ActionEvent actionEvent) {
if (this.menuPanel != null) this.remove(menuPanel);
menuPanel = new ScoreMenu(scale(170), scale(40), scale(220), scale(226), this);
menuPanel.setBackground(Color.DARK_GRAY);
menuPanel.setBorder(new LineBorder(Color.GRAY, scale(2)));
menuPanel.setBackground(CatppuccinColor.BASE.getColor());
menuPanel.setBorder(new LineBorder(CatppuccinColor.SURFACE0.getColor(), scale(2)));
this.add(menuPanel);
this.repaint();
}
@@ -152,7 +153,7 @@ public class TetrisUI extends JFrame implements KeyListener {
case KeyEvent.VK_W:
Tetris.getSpace().getCurrentTetromino().rotate();
break;
case KeyEvent.VK_DOWN:
case KeyEvent.VK_RIGHT:
case KeyEvent.VK_D:
Tetris.getSpace().getCurrentTetromino().move(1);
break;
@@ -160,7 +161,7 @@ public class TetrisUI extends JFrame implements KeyListener {
case KeyEvent.VK_A:
Tetris.getSpace().getCurrentTetromino().move(-1);
break;
case KeyEvent.VK_RIGHT:
case KeyEvent.VK_DOWN:
case KeyEvent.VK_S:
Tetris.getSpace().getCurrentTetromino().fall(1);
break;

View File

@@ -0,0 +1,19 @@
package eu.midnightdust.yaytris.util;
import java.awt.*;
/*
Colors based on the [Catppuccin Mocha](https://github.com/catppuccin/catppuccin) color palette
*/
public enum CatppuccinColor {
CRUST(0x11111b), MANTLE(0x181825), BASE(0x1e1e2e), SURFACE0(0x313244);
final Color color;
CatppuccinColor(int rgb) {
this.color = new Color(rgb);
}
public Color getColor() {
return color;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 B

After

Width:  |  Height:  |  Size: 154 B