资源简介
大二刚学java时写的一个俄罗斯方块程序,整个项目都压缩放上来了,供有兴趣的朋友参考
代码片段和文件信息
/*
* To change this template choose Tools | Templates
* and open the template in the editor.
*/
package tezis;
public class Block implements Runnable {
//用二维数组保存
static int[][] blocks = {
{0x000f 0x8888 0x000f 0x8888}//用十六进至表示,本行表示长条四种状态
{0x004e 0x0464 0x00e4 0x04c4}
{0x0462 0x006c 0x0462 0x006c}
{0x0264 0x00c6 0x0264 0x00c6}
{0x0622 0x0017 0x0446 0x0074}
{0x0644 0x00e2 0x044c 0x008e}
{0x0066 0x0066 0x0066 0x0066}
};
int blockType; //块的模式号(0-6)
int turnState;
int X Y; //块在画布上的坐标
Tetris tetris;
//方块自由下落线程
Thread down = null;
//速度控制变量
int ymove = 1;
int seconds = 750;
int speed = 0;
//保存下一个方块
int nextType = 0;
int nextState = 0;
Block(Tetris tetris) {
this.tetris = tetris;
blockType = (int) (Math.random() * 1000) % 7;
turnState = (int) (Math.random() * 1000) % 4;
X = tetris.initX;
Y = tetris.initY;
this.dispBlock(1);
down = new Thread(this);
down.start();
}
//NEXT显示
public void next() {
nextType = (int) (Math.random() * 1000) % 7;
nextState = (int) (Math.random() * 1000) % 4;
int k = 0x8000;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
tetris.nextBlock[i][j] = 0;
}
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if (((int) blocks[nextType][nextState] & k) != 0) {
tetris.nextBlock[j][i] = 1;
}
k = k >> 1;
}
}
}
public synchronized void reset() {
blockType = nextType;
turnState = nextState;
X = tetris.initX;
Y = tetris.initY;
ymove = 1;
tetris.flag = 2;
tetris.fullLine.removeAllElements();
this.next();
}
//右移
public void rightMove() {
if (this.canRight(blockType turnState 0) && !this.pause()) {
dispBlock(0);
X++;
dispBlock(1);
}
}
//左移
public void leftMove() {
if (this.canLeft(blockType turnState 0) && !this.pause()) {
dispBlock(0);
X--;
dispBlock(1);
}
}
//翻转
public void turn() {
if (this.isActive(blockType turnState X Y) && this.canRight(blockType
(turnState+1) % 41) && this.canLeft(blockType (turnState+1) % 41)
&& !this.pause()) {
dispBlock(0);
turnState = (turnState + 1) % 4;
dispBlock(1);
}
}
//判断是否可以左移
public boolean canLeft(int t int sint type) {
int k = 0x8000;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if (type == 0) {
if ((int) (blocks[t][
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 101 2010-06-25 22:31 Tezis\build\built-jar.properties
文件 0 2010-06-25 22:58 Tezis\build\classes\.netbeans_automatic_build
文件 4485 2010-08-21 22:46 Tezis\build\classes\tezis\Block.class
文件 1492 2010-08-21 22:46 Tezis\build\classes\tezis\SValue.class
文件 7823 2010-08-21 22:46 Tezis\build\classes\tezis\Tetris.class
文件 3710 2010-05-17 13:01 Tezis\build.xm
文件 1444 2010-06-25 22:31 Tezis\dist\README.TXT
文件 85 2010-05-17 13:01 Tezis\manifest.mf
文件 43230 2010-05-17 13:01 Tezis\nbproject\build-impl.xm
文件 475 2010-05-17 13:01 Tezis\nbproject\genfiles.properties
文件 175 2010-08-21 22:46 Tezis\nbproject\private\private.properties
文件 211 2010-07-18 09:58 Tezis\nbproject\private\private.xm
文件 2035 2010-05-17 19:50 Tezis\nbproject\project.properties
文件 513 2010-05-17 13:01 Tezis\nbproject\project.xm
文件 7270 2010-05-31 13:14 Tezis\src\tezis\Block.java
文件 1641 2010-07-18 09:58 Tezis\src\tezis\SValue.java
文件 10442 2010-07-18 08:47 Tezis\src\tezis\Tetris.java
文件 176389 2010-05-27 10:28 Tezis\src\俄罗斯方块\bg.jpg
文件 34224 2010-06-15 15:53 Tezis\src\俄罗斯方块\bg1.jpg
文件 111170 2010-05-23 11:26 Tezis\src\俄罗斯方块\bg2.jpg
文件 11698 2010-05-30 20:16 Tezis\src\俄罗斯方块\block.jpg
文件 10959 2010-05-20 10:32 Tezis\src\俄罗斯方块\block1 - 副本.jpg
文件 11653 2010-05-30 20:20 Tezis\src\俄罗斯方块\block1.jpg
文件 10956 2010-05-18 08:41 Tezis\src\俄罗斯方块\block2.jpg
文件 18169 2010-06-04 09:55 Tezis\src\俄罗斯方块\tetris.docx
文件 3374 2010-05-18 09:36 Tezis\src\俄罗斯方块\新建文本文档.txt
目录 0 2010-09-26 18:58 Tezis\build\classes\tezis
目录 0 2010-09-26 18:58 Tezis\build\classes
目录 0 2010-06-25 22:31 Tezis\build\empty
目录 0 2010-09-26 18:58 Tezis\nbproject\private
............此处省略11个文件信息
相关资源
- 基于java web的医院网上预约挂号系统
- QQ-java源码-UML分析图-多人聊天2010
- 编译原理词法分析,语法分析,中间
- Java课程设计俄罗斯方块小游戏
- 基于java博客网站的设计与实现开题报
- 学生信息管理系统 源代码,打包程序
- 基于java的图书管理系统
- 超市商品购物管理系统
- 中南大学java实验报告
- Kafka全面教程,适合项目实战包括源码
- SQL数据库+java学生成绩管理系统
- javaee 实验1 JSP+Servlet+JavaBean编程
- JAVA面试重点话术张大大吐血整理.do
- java题库试卷管理系统
- PL0词法分析器java实现
- java算法分析与设计之哈夫曼编码源代
- java+sql2005实现宿舍管理系统
- java 小学生算数测试系统
- java项目-学生管理系统
- 用Java编写的通讯录管理系统
- 词法分析器(java版有UI界面).zip
- 使用C++语言实现基于JVMTI机制的 JAVA
- java做图书管理系统
- 图书销售管理系统Java源代码
- 毕业设计java俄罗斯方块游戏及论文
- 运用java设计模式写的俄罗斯方块游戏
- 用三个线程分别计算平均值,最大值
- java设计模式精讲 Debug 方式+内存分析
- JavaCC实现MiniC语言的编译
- Java愤怒的小鸟控制台游戏不含数据库
评论
共有 条评论