java课程设计-贪吃蛇代码
发布时间:2021-06-06
发布时间:2021-06-06
import java.awt.Color;
import ponent;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
public class SnakeGame {
public static void main(String[] args) {
SnakeFrame frame = new SnakeFrame();
frame.setTitle("贪吃蛇");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
// ----------记录状态的线程
class StatusRunnable implements Runnable {
public StatusRunnable(Snake snake, JLabel statusLabel, JLabel scoreLabel) { this.statusLabel = statusLabel;
this.scoreLabel = scoreLabel;
this.snake = snake;
}
public void run() {
String sta = "";
String spe = "";
while (true) {
switch (snake.status) {
case Snake.RUNNING:
sta = "Running";
break;
case Snake.PAUSED:
上一篇:硬笔书法 第一课时
下一篇:《聪明人和傻子和奴才》教学设计