src/Snake/Yard.java
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
package Snake;
import java.awt.*;
import java.awt.event.*;
/**
* java小项目:贪吃蛇游戏<br>
* 通过上下左右方向箭头控制贪吃蛇的移动<br>
* 当蛇碰壁或者碰到自己时游戏结束,按F2开始新游戏<br>
* @author Shine_rise
*
*/
public class Yard extends Frame {
public static final int ROWS = 30;
public static final int COLUMNS = 40;
public static final int BLOCK_SIZE = 15;
private static final int GAME_WIDTH = COLUMNS * BLOCK_SIZE;
private static final int GAME_HEIGHT = ROWS * BLOCK_SIZE;
//本代码来自www.51Aspx.com
private boolean gameOver = false;
public boolean isGameOver() {
return gameOver;
}
public void setGameOver(boolean gameOver) {
this.gameOver = gameOver;
}
private int score = 0;
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
PaintThread paintThread = new PaintThread();
Image offStreamImage = null;
Snake s = new Snake(this);
Egg e = new Egg();
public static void main(String[] args) {
new Yard().launchFrame();
}
public void launchFrame() {
this.setTitle("贪吃蛇");
this.setLocation(300, 200);
this.setResizable(false);
this.setBackground(Color.LIGHT_GRAY);
this.setSize(GAME_WIDTH, GAME_HEIGHT);
this.setVisible(true);
后面还有 99 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。