diff --git a/scr/tetris/PreparePanel.java b/scr/tetris/PreparePanel.java deleted file mode 100644 index 2557cd0..0000000 --- a/scr/tetris/PreparePanel.java +++ /dev/null @@ -1,43 +0,0 @@ -package tetris; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; - -public class PreparePanel extends JPanel { - private final ResourceManager res; - private Runnable startCallback; - - public PreparePanel(Runnable startGame) { - this.res = ResourceManager.getInstance(); - this.startCallback = startGame; - setPreferredSize(new Dimension(510, 650)); - initControls(); - } - - private void initControls() { - addKeyListener(new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_SPACE) { - res.stopPrepareMusic(); - startCallback.run(); - } - } - }); - setFocusable(true); - } - - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - g.drawImage(res.getPrepareBackground(), 0, 0, getWidth(), getHeight(), this); - - g.setColor(Color.WHITE); - g.setFont(new Font("微软雅黑", Font.BOLD, 24)); - String text = "按空格键开始游戏"; - int textWidth = g.getFontMetrics().stringWidth(text); - g.drawString(text, (getWidth() - textWidth) / 2, getHeight() - 80); - } -} \ No newline at end of file