java课程设计-贪吃蛇代码(7)
发布时间:2021-06-06
发布时间:2021-06-06
g.setColor(Color.blue);
g.fillRect(node.x, node.y, node.H, node.W);
}
}
class SnakeFrame extends JFrame {
private JLabel statusLabel;
private JLabel speedLabel;
private JLabel scoreLabel;
private JPanel snakePanel;
private Snake snake;
private JMenuBar bar;
JMenu gameMenu;
JMenu helpMenu;
JMenu speedMenu;
JMenuItem newItem;
JMenuItem pauseItem;
JMenuItem beginItem;
JMenuItem helpItem;
JMenuItem aboutItem;
JMenuItem slowItem;
JMenuItem midItem;
JMenuItem fastItem;
public SnakeFrame() {
init();
ActionListener l = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == pauseItem)
snake.isRun = false;
if (e.getSource() == beginItem)
snake.isRun = true;
if (e.getSource() == newItem) {
newGame();
}
// ------------菜单控制运行速度
if (e.getSource() == slowItem) {
snake.speed = Snake.SLOW;
speedLabel.setText("Slow");
}
if (e.getSource() == midItem) {
snake.speed = Snake.MID;
speedLabel.setText("Mid");
}
上一篇:硬笔书法 第一课时
下一篇:《聪明人和傻子和奴才》教学设计