feat: improve texture & design
This commit is contained in:
@@ -52,8 +52,10 @@ public class Tetris {
|
|||||||
};
|
};
|
||||||
timer.scheduleAtFixedRate(gravityTask, 1, Settings.difficulty.getTimerPeriod());
|
timer.scheduleAtFixedRate(gravityTask, 1, Settings.difficulty.getTimerPeriod());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stopGame() {
|
public static void stopGame() {
|
||||||
gravityTask.cancel();
|
gravityTask.cancel();
|
||||||
|
timer.purge();
|
||||||
if (ui.getMenuPanel() instanceof ScoreMenu) ((ScoreMenu) Tetris.ui.getMenuPanel()).gameOver();
|
if (ui.getMenuPanel() instanceof ScoreMenu) ((ScoreMenu) Tetris.ui.getMenuPanel()).gameOver();
|
||||||
ui.transferFocus();
|
ui.transferFocus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package eu.midnightdust.yaytris.ui;
|
|||||||
|
|
||||||
import eu.midnightdust.yaytris.Tetris;
|
import eu.midnightdust.yaytris.Tetris;
|
||||||
import eu.midnightdust.yaytris.game.Space;
|
import eu.midnightdust.yaytris.game.Space;
|
||||||
|
import eu.midnightdust.yaytris.util.CatppuccinColor;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -25,7 +26,7 @@ public class TetrisUI extends JFrame implements KeyListener {
|
|||||||
this.setTitle("Tetris");
|
this.setTitle("Tetris");
|
||||||
this.setSize((int) (400 * guiScale), (int) (300 * guiScale));
|
this.setSize((int) (400 * guiScale), (int) (300 * guiScale));
|
||||||
this.setResizable(false);
|
this.setResizable(false);
|
||||||
this.getContentPane().setBackground(Color.DARK_GRAY);
|
this.getContentPane().setBackground(CatppuccinColor.MANTLE.getColor());
|
||||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
setWindowPosition(this, 0);
|
setWindowPosition(this, 0);
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ public class TetrisUI extends JFrame implements KeyListener {
|
|||||||
|
|
||||||
gamePanel = new GameCanvas(this);
|
gamePanel = new GameCanvas(this);
|
||||||
gamePanel.setBackground(Color.BLACK);
|
gamePanel.setBackground(Color.BLACK);
|
||||||
gamePanel.setBorder(new LineBorder(Color.GRAY, scale(2)));
|
gamePanel.setBorder(new LineBorder(CatppuccinColor.SURFACE0.getColor(), scale(2)));
|
||||||
this.add(gamePanel);
|
this.add(gamePanel);
|
||||||
|
|
||||||
rescale();
|
rescale();
|
||||||
@@ -91,8 +92,8 @@ public class TetrisUI extends JFrame implements KeyListener {
|
|||||||
Tetris.resetSpace();
|
Tetris.resetSpace();
|
||||||
rescale();
|
rescale();
|
||||||
menuPanel = new MainMenu(scale(170), scale(40), scale(220), scale(226), this);
|
menuPanel = new MainMenu(scale(170), scale(40), scale(220), scale(226), this);
|
||||||
menuPanel.setBackground(Color.DARK_GRAY);
|
menuPanel.setBackground(CatppuccinColor.BASE.getColor());
|
||||||
menuPanel.setBorder(new LineBorder(Color.GRAY, scale(2)));
|
menuPanel.setBorder(new LineBorder(CatppuccinColor.SURFACE0.getColor(), scale(2)));
|
||||||
this.add(menuPanel);
|
this.add(menuPanel);
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}
|
}
|
||||||
@@ -100,8 +101,8 @@ public class TetrisUI extends JFrame implements KeyListener {
|
|||||||
public void openSettings(ActionEvent actionEvent) {
|
public void openSettings(ActionEvent actionEvent) {
|
||||||
if (this.menuPanel != null) this.remove(menuPanel);
|
if (this.menuPanel != null) this.remove(menuPanel);
|
||||||
menuPanel = new SettingsMenu(scale(170), scale(40), scale(220), scale(226), this);
|
menuPanel = new SettingsMenu(scale(170), scale(40), scale(220), scale(226), this);
|
||||||
menuPanel.setBackground(Color.DARK_GRAY);
|
menuPanel.setBackground(CatppuccinColor.BASE.getColor());
|
||||||
menuPanel.setBorder(new LineBorder(Color.GRAY, scale(2)));
|
menuPanel.setBorder(new LineBorder(CatppuccinColor.SURFACE0.getColor(), scale(2)));
|
||||||
this.add(menuPanel);
|
this.add(menuPanel);
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}
|
}
|
||||||
@@ -109,8 +110,8 @@ public class TetrisUI extends JFrame implements KeyListener {
|
|||||||
public void openScoreMenu(ActionEvent actionEvent) {
|
public void openScoreMenu(ActionEvent actionEvent) {
|
||||||
if (this.menuPanel != null) this.remove(menuPanel);
|
if (this.menuPanel != null) this.remove(menuPanel);
|
||||||
menuPanel = new ScoreMenu(scale(170), scale(40), scale(220), scale(226), this);
|
menuPanel = new ScoreMenu(scale(170), scale(40), scale(220), scale(226), this);
|
||||||
menuPanel.setBackground(Color.DARK_GRAY);
|
menuPanel.setBackground(CatppuccinColor.BASE.getColor());
|
||||||
menuPanel.setBorder(new LineBorder(Color.GRAY, scale(2)));
|
menuPanel.setBorder(new LineBorder(CatppuccinColor.SURFACE0.getColor(), scale(2)));
|
||||||
this.add(menuPanel);
|
this.add(menuPanel);
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}
|
}
|
||||||
@@ -152,7 +153,7 @@ public class TetrisUI extends JFrame implements KeyListener {
|
|||||||
case KeyEvent.VK_W:
|
case KeyEvent.VK_W:
|
||||||
Tetris.getSpace().getCurrentTetromino().rotate();
|
Tetris.getSpace().getCurrentTetromino().rotate();
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_DOWN:
|
case KeyEvent.VK_RIGHT:
|
||||||
case KeyEvent.VK_D:
|
case KeyEvent.VK_D:
|
||||||
Tetris.getSpace().getCurrentTetromino().move(1);
|
Tetris.getSpace().getCurrentTetromino().move(1);
|
||||||
break;
|
break;
|
||||||
@@ -160,7 +161,7 @@ public class TetrisUI extends JFrame implements KeyListener {
|
|||||||
case KeyEvent.VK_A:
|
case KeyEvent.VK_A:
|
||||||
Tetris.getSpace().getCurrentTetromino().move(-1);
|
Tetris.getSpace().getCurrentTetromino().move(-1);
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_RIGHT:
|
case KeyEvent.VK_DOWN:
|
||||||
case KeyEvent.VK_S:
|
case KeyEvent.VK_S:
|
||||||
Tetris.getSpace().getCurrentTetromino().fall(1);
|
Tetris.getSpace().getCurrentTetromino().fall(1);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -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 |
Binary file not shown.
Reference in New Issue
Block a user