public class GreedSnake implements KeyListener { JFrame mainFrame; Canvas paintCanvas; JLabel labelScore;//计分牌 SnakeModel snakeModel=null;// 蛇 public static final int canvasWidth=200; public static final int canvasHeight=300; public static final int
简单的游戏选择界面 使用Canvas // 计算整个菜单的高度,宽度和(x,y) int rectWidth = Width; int rectHeight = Height * b.length; int x = (getWidth() - rectWidth) / 2; int y = (getHeight() - rectHeight) / 2; // 画矩形 g.drawRect(x, y, rectWidth, rectHeight); for (int i = 1; i <