[俄罗斯方块java代码]FLASH游戏之俄罗斯方块源代码
[俄罗斯方块java代码]FLASH游戏之俄罗
斯方块源代码
篇一 : FLASH游戏之俄罗斯方块源代码
N=20;
//行数
WIDTH=20;
//方块边长
level=0;
//开始等级
ret=newArray;
//当前出现的方块
nextret=newArray;
//下一个出现的方块
bg=newArray;
//背景数组
createEmptyMovieClip;
//所有方块都在此mc里
for{
//初始化方块数组,2*5格式,前四行代表每个方块的4个小块的位置坐标,最后一行第一列是方块形状,第二列是方块旋转方向
ret.push);
nextret.push);
}
for{
//初始化背景数组,10*20格式
bg.push);
}
X=Y=panel._x=panel._y=0;
//换为X、Y表示
functionreach{
//x、y为方块位置,ret为方块形状,若方块ret下落一格碰到
边界或者方块返回1vari:Number,j:Number,k:Number;
for{
for{
if{
for{
if{
return1;
}
}
}
}
}
return0;
}
functionlrnotout{
//lorr==-1代表a往左边一格可行性的判断,lorr==1代表右边
一格可行性的判断,lorr==0
代表a的位置合理性的判断,出现不合理则返回0
vari:Number;
if{
for{
if){
return0;
}
}
}
if{
for{
if){
return0;
}
}
}
if{
for{
if{
return0;
}
}
}
return1;
}
functionrv{
//方块赋值,将a方块赋值到ret方块
vari:Number;
for{
ret[i][0]=a[i][0],ret[i][1]=a[i][1];
}
}
functionrotate{
//根据方块ret最后一行为ret的前四行赋以具体形状值
switch{
case0:
//方形
a=[[1,0],[2,0],[1,1],[2,1],[0,0]];
rv;
return;
case1:
//长形
switch{
case1:
a=[[0,0],[1,0],[2,0],[3,0],[1,0]];if&&!reach){
rv;
}
return;
case0:
a=[[1,0],[1,1],[1,2],[1,3],[1,1]];if&&!reach){
rv;
}
return;
}
case2:
//Z形
switch{
case1:
a=[[0,1],[1,1],[1,2],[2,2],[2,0]];if&&!reach){
rv;
}
return;
case0:
a=[[2,0],[1,1],[2,1],[1,2],[2,1]];if&&!reach){
rv;
}
return;
}
case3:
//反Z形
switch{
case1:
a=[[1,1],[2,1],[0,2],[1,2],[3,0]];if&&!reach){
rv;
}
return;
case0:
a=[[1,0],[1,1],[2,1],[2,2],[3,1]];if&&!reach){
rv;
}
return;
}
case4:
//T形
switch{
case3:
a=[[1,0],[0,1],[1,1],[2,1],[4,0]];if&&!reach){
rv;
}
return;
case0:
a=[[1,0],[0,1],[1,1],[1,2],[4,1]];if&&!reach){
rv;
}
return;
case1:
a=[[0,1],[1,1],[2,1],[1,2],[4,2]];if&&!reach){
rv;
}
return;
case2:
a=[[1,0],[1,1],[2,1],[1,2],[4,3]];if&&!reach){
rv;
}
return;
}
case5:
//倒L形
switch{
case3:
a=[[1,0],[2,0],[1,1],[1,2],[5,0]];if&&!reach){
rv;
}
return;
case0:
a=[[0,1],[0,2],[1,2],[2,2],[5,1]];if&&!reach){
rv;
}
return;
case1:
a=[[2,0],[2,1],[1,2],[2,2],[5,2]];if&&!reach){
rv;
}
return;
case2:
a=[[0,1],[1,1],[2,1],[2,2],[5,3]];if&&!reach){
rv;
}
return;
}
case6:
//L形
switch{
case3:
a=[[1,0],[2,0],[2,1],[2,2],[6,0]];if&&!reach){
rv;
}
return;
case0:
a=[[0,1],[1,1],[2,1],[0,2],[6,1]];if&&!reach){
rv;
}
return;
case1:
a=[[1,0],[1,1],[1,2],[2,2],[6,2]];if&&!reach){
rv;
}
return;
case2:
a=[[2,1],[0,2],[1,2],[2,2],[6,3]];if&&!reach){
rv;
}
return;
}
}
}
functiongenerate{
//随机产生方块函数ret[4][0]=Math.floor*7);ret[4][1]=Math.floor*4);rotate;
//完成方块ret的具体形状的赋值}
functioninit{
//初始化背景、方块、运动函数vari:Number,j:Number;
for{
//初始化背景,边界为1,其余为??for{
if{
bg[i][j]=1;
}else{
bg[i][j]=„„;
}
}
}
for{
//为当前方块赋初值0
ret[i][0]=ret[i][1]=0;
}
generate;
//产生当前方块
generate;
//产生下一个方块
y=0,x=3,score=lines=0,level=0;//当前位置坐标和计分系统初始化_tetris.removeTextField;
//如果从结束过的游戏恢复,删除结束标志display;
//显示画面
frameflag=0;
//标示下落时间间隔
onEnterFrame=function{
frameflag++;
if{
//根据等级level确定下落时间间隔frameflag=0;
go;
//下落及判断
}
};
}
functiondrawblock{
//绘制方块的小块
with{
beginFill;
lineStyle;
moveTo;
lineTo;
lineTo;
lineTo;
lineTo;
endFill;
}
}
functionerase{
//删除一行方块
varn:Number=0,i:Number,j:Number,k:Number,l:Number;for{
for{
if{
//如果该行有空,则开始判断下一行
i++,j=-1;
if{
//行N-1为底线,不判断
break;
}
}elseif{
//判断到该行最后一列都没有空
for{
//上方方块下落
for{
bg[k][l]=bg[k-1][l];
}
}
for{
//删除该行
bg[0][l]=„„;
}
n++;
//此次删除行数变量增一
if%30==0){
//删除行数总数到30的倍数则等级上升
level=%10;
}
}
}
}
lines+=n,score+=*50;
//总行数增n,计算得分
}
functiondisplay{
//显示函数,采用全部清除再重绘制的方法
vari:Number,j:Number;
panel.clear;
with{
//画边界
lineStyle;
moveTo;
lineTo;
lineTo);
lineTo);
lineTo;
}
for{
//当前方块占据的地方赋值为边界类型1
bg[y+ret[i][1]][x+ret[i][0]]=1;
}
for{
//绘制背景方块
for{
if{
drawblock;
}
}
}
for{
//绘制当前方块
drawblock;
}
for{
//当前方块绘制完毕,重新将当前位置改为??
bg[y+ret[i][1]][x+ret[i][0]]=„„;
}
createTextField;
//绘制计分系统
createTextField;
createTextField;
_lvltxt.text=“Level:”+level;
_scrtxt.text=“Score:”+score;
_lnstxt.text=“Lines:”+lines;
}
functiongo{
//下落函数
if)){
//当前方块下落一格是否碰到边界或方块
y++;
//如果当前方块下落一格没有碰到边界或方块则下落一格
display;
//重新绘制
}
else{
//碰到边界或方块
score+=10;
//得10分
display;
//重新绘制
for{
//修改背景数组,将当前方块的位置改为边界类型
bg[y+ret[ii][1]][x+ret[ii][0]]=1;
}
erase;
//删除行判断及执行
rv;
//将下一个方块赋值为当前方块
y=0,x=3;
//重置方块位置
generate;
//生成下一个方块
display;
//重新绘制
if){
//如果下一格碰到方块则游戏结束
createTextField;_tetris._x+=200;
_tetris._y+=50;
_tetris._xscale=300;
_tetris._yscale=300;
_tetris.background=true;
_tetris.text=“GameOver!”;onEnterFrame=function{
//停止下落
};
}
}
}
functionkey{
if){
rotate;
display;
}
if){
if){
//左移可行性判断
x--;
display;
}
}
if){
if){
//右移可行性判断
x++;
display;
}
}
if){
//键盘控制下落
go;
}
if){
//一键下落到底
while){
y++;
}
go;
}
if){
//重新开始游戏
init;
}
}
init;
//初始化
setInterval;
//每个80毫秒执行一次键盘事件函数
createTextField;hinttxt.text=“键盘键:上,下,左,右,R,空格”;
篇二 : JAVA俄罗斯方块源代码
不多说,,直接可以拷贝下面的东西,然后记得把那个BLOCK
的名字改成你自己的类名,这个很关键哦,不然是错的可别怪我,呵
呵~~
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
import java.lang.String.*;
import java.lang.*;
import java.io.*;
public class Block extends JPanel implements
ActionListener,KeyListener//应该是继承JPanel
{
static Button but[] = new Button[6];
static Button noStop = new Button;
static Label scoreLab = new Label;
static Label infoLab = new Label;
static Label speedLab = new Label;
static Label scoreTex = new Label;
static Label infoTex = new Label;
static Label speedTex = new Label;
static JFrame jf = new JFrame;
static MyTimer timer;
static ImageIcon icon=new ImageIcon; static JMenuBar mb = new
JMenuBar;
static JMenu menu0 = new JMenu;
static JMenu menu1 = new JMenu;
static JMenuItem mi0 = new JMenuItem;
static JMenuItem mi1 = new JMenuItem;
static JMenuItem mi1_0 = new JMenuItem;
static JDialog dlg_1;
static JTextArea dlg_1_text = new JTextArea;
static int startSign = 0;//游戏开始标志 0 未开始 1 开始 2 暂
停
static String butLab[] = {“开 始 游 戏”,”重 新 开 始”,”降 低
级 数”,”提 高 级 数”,”游 戏 暂 停”,”退 出 游 戏”};
static int game_body[][] = new int[19][10];
static int game_sign_x[] = new int[4];//用于记录4个方格的水平
位置 static int game_sign_y[] = new int[4];//用于记录4个方格的垂直
位置 static boolean downSign = false;//是否落下
static int blockNumber = 1;//砖块的编号
static int gameScore = 0;//游戏分数
static int speedMark = 1;
public static void main {
Block myBlock = new Block;
mb.add;
mb.add;
menu0.add;
menu0.add;
menu1.add;
jf.setJMenuBar;
myBlock.init;
jf.add;
jf.setSize;
jf.setResizable;
jf.setTitle;
jf.setIconImage);
jf.setLocation;
jftimer = new MyTimer; //启动线程 timer.setDaemon;
timer.start;
timer}
public void init
{
setLayout;
for
{
but[i] = new Button;
add;
but[i].addActionListener;
but[i].addKeyListener;
but[i].setBounds,160,25); }
add;
add;
add;
add;
add;
add;
add;
scoreLab.setBounds;
scoreTex.setBounds;
scoreTex.setBackground;
speedLab.setBounds;
speedTex.setBounds;
speedTex.setBackground;
but[1].setEnabled;
but[4].setEnabled;
infoLab.setBounds;
infoTex.setBounds;
infoTex.setBackground;
noStop.setBounds;
noStop.addActionListener;
noStop.addKeyListener;
mi0.addActionListener;
mi1.addActionListener;
mi1_0.addActionListener;
num_csh_game;
rand_block;
}
public void actionPerformed
{
if == but[0])//开始游戏
{
startSign = 1;
infoTex.setText;
but[0].setEnabled;
but[1].setEnabled;
but[4].setEnabled;
timer }
if == but[1]||e.getSource == mi0)//重新开始游戏 {
startSign = 0;
gameScore = 0;
timer num_csh_restart;
repaint;
rand_block;
scoreTex.setText;
infoTex.setText;
but[0].setEnabled;
but[1].setEnabled;
but[4].setEnabled;
}
if == but[2])//降低级数
{
infoTex.setText;
speedMark--;
if
{
speedMark = 1;
infoTex.setText;
}
speedTex.setText;
}
if == but[3])//提高级数
{
infoTex.setText;
speedMark++;
if
{
speedMark = 9;
infoTex.setText;
}
speedTex.setText;
}
if == but[4])//游戏暂停
{
this.add;
this.remove; 扩展:java俄罗斯方块代码 / java俄罗斯方块 /
java经典编程300例
infoTex.setText;
timer }
if == noStop)//取消暂停
{
this.remove;
this.add;
infoTex.setText;
timer }
if == but[5]||e.getSource == mi1)//退出游戏 {
jf.dispose;
}
if == mi1_0)//退出游戏
{
dlg_1 = new JDialog;
try{
FileInputStream io = FileInputStream;//得到路径 byte a[] = new
byte[io.available];
io.read;
io.close;
String str = new String;
dlg_1_text.setText;
}
catch{}
dlg_1_text.setEditable;
dlg_1.add;
dlg_1.pack;
dlg_1.setResizable;
dlg_1.setSize;
dlg_1.setLocation;
dlg_1 }
}
public void rand_block//随机产生砖块
{
int num;
num = * 6) + 1;//产生0~6之间的随机数 blockNumber = num;
switch
{
case 1: block1; blockNumber = 1; break;
case 2: block2; blockNumber = 2; break;
case 3: block3; blockNumber = 3; break;
case 4: block4; blockNumber = 4; break;
case 5: block5; blockNumber = 5; break;
case 6: block6; blockNumber = 6; break;
case 7: block7; blockNumber = 7; break;
}
}
public void change_body//改变砖块状态 {
dingwei;
if//变换长条2种情况 {
if//说明new
长条是横着的
{
if {
num_csh_game;
game_body[game_sign_y[0] - 1][game_sign_x[0] + 1] = 1;
game_body[game_sign_y[1]][game_sign_x[1]] = 1;
game_body[game_sign_y[2] + 1][game_sign_x[2] - 1] = 1;
game_body[game_sign_y[3] + 2][game_sign_x[3] - 2] = 1;
infoTex.setText;
repaint;
}
}
if//说明长条是竖着的
{
if {
num_csh_game;
game_body[game_sign_y[0] + 1][game_sign_x[0] - 1] = 1;
game_body[game_sign_y[1]][game_sign_x[1]]=1;
game_body[game_sign_y[2] - 1][game_sign_x[2] + 1] = 1;
game_body[game_sign_y[3] - 2][game_sign_x[3] + 2] = 1;
infoTex.setText;
repaint;
}
}
}
if//变换转弯1有4种情况
{
if
{
if
{
num_csh_game;
game_body[game_sign_y[0] + 1][game_sign_x[0] - 1] = 1;
game_body[game_sign_y[1]][game_sign_x[1]] = 1; >= !=
game_body[game_sign_y[2] - 1][game_sign_x[2] + 1] = 1;
game_body[game_sign_y[3] - 2][game_sign_x[3]] = 1;
infoTex.setText;
repaint;
}
}
if
{
if
{
num_csh_game;
game_body[game_sign_y[0]][game_sign_x[0] - 2] = 1;
game_body[game_sign_y[1] + 1][game_sign_x[1] + 1] = 1;
game_body[game_sign_y[2]][game_sign_x[2]] = 1;
game_body[game_sign_y[3] - 1][game_sign_x[3] - 1] = 1;
infoTex.setText;
repaint;
}
}
if
{
if
{
num_csh_game;
game_body[game_sign_y[0] + 2][game_sign_x[0]] = 1;
game_body[game_sign_y[1] + 1][game_sign_x[1] - 1] = 1;
game_body[game_sign_y[2]][game_sign_x[2]] = 1;
扩展:java俄罗斯方块代码 / java俄罗斯方块 / java经典编程
300例
game_body[game_sign_y[3] - 1][game_sign_x[3] + 1] = 1;
infoTex.setText;
repaint;
}
}
if
{
if
{
num_csh_game;
game_body[game_sign_y[0] + 1][game_sign_x[0] + 1] = 1;
game_body[game_sign_y[1]][game_sign_x[1]] = 1;
game_body[game_sign_y[2] - 1][game_sign_x[2] - 1] = 1;
game_body[game_sign_y[3]][game_sign_x[3] + 2] = 1;
infoTex.setText;
repaint;
}
}
}
if//变换转弯2有4种情况
{
if
{
if
{
num_csh_game;
game_body[game_sign_y[0] + 2][game_sign_x[0]] = 1;
game_body[game_sign_y[1] + 1][game_sign_x[1] + 1] = 1;
game_body[game_sign_y[2]][game_sign_x[2]] = 1;
game_body[game_sign_y[3]][game_sign_x[3] + 2] = 1;
infoTex.setText;
repaint;
}
}
if
{
if
{
num_csh_game;
game_body[game_sign_y[0]][game_sign_x[0]] = 1;
game_body[game_sign_y[1]][game_sign_x[1] + 2] = 1;
game_body[game_sign_y[2] - 1][game_sign_x[2] + 1] = 1;
game_body[game_sign_y[3] - 2][game_sign_x[3]] = 1;
infoTex.setText;
repaint;
}
}
if
{
if
{
num_csh_game;
game_body[game_sign_y[0]][game_sign_x[0] - 2] = 1;
game_body[game_sign_y[1]][game_sign_x[1]] = 1;
game_body[game_sign_y[2] - 1][game_sign_x[2] - 1] = 1;
game_body[game_sign_y[3] - 2][game_sign_x[3]] = 1;
infoTex.setText;
repaint;
}
}
if
{
if
{
num_csh_game;
game_body[game_sign_y[0] + 2][game_sign_x[0]] = 1;
game_body[game_sign_y[1] + 1][game_sign_x[1] - 1] = 1;
game_body[game_sign_y[2]][game_sign_x[2] - 2] = 1;
game_body[game_sign_y[3]][game_sign_x[3]] = 1;
infoTex.setText;
repaint;
}
}
}
if//变换转弯3有4种情况
{
if
{
if
{
num_csh_game;
game_body[game_sign_y[0] + 1][game_sign_x[0] - 1] = 1;
game_body[game_sign_y[1]][game_sign_x[1] - 2] = 1;
game_body[game_sign_y[2]][game_sign_x[2]] = 1;
game_body[game_sign_y[3] - 1][game_sign_x[3] + 1] = 1;
infoTex.setText;
repaint;
}
}
if
{
if
{
num_csh_game;
game_body[game_sign_y[0] + 2][game_sign_x[0]] = 1; 扩
展:java俄罗斯方块代码 / java俄罗斯方块 / java经典编程300例
game_body[game_sign_y[1] + 1][game_sign_x[1] + 1] = 1; game_body[game_sign_y[2]][game_sign_x[2]] = 1;
game_body[game_sign_y[3] - 1][game_sign_x[3] - 1] = 1; + + 2][game_sign_x[0]] + 1] != != 1][game_sign_x[1]
infoTex.setText;
repaint;
}
}
if
{
if
{
num_csh_game;
game_body[game_sign_y[0] + 1][game_sign_x[0] - 1] = 1;
game_body[game_sign_y[1]][game_sign_x[1]] = 1;
game_body[game_sign_y[2]][game_sign_x[2] + 2] = 1;
game_body[game_sign_y[3] - 1][game_sign_x[3] + 1] = 1;
infoTex.setText;
repaint;
}
}
if
{ ==
if
{
num_csh_game;
game_body[game_sign_y[0] + 1][game_sign_x[0] + 1] = 1;
game_body[game_sign_y[1]][game_sign_x[1]] = 1;
game_body[game_sign_y[2] - 1][game_sign_x[2] - 1] = 1;
game_body[game_sign_y[3] - 2][game_sign_x[3]] = 1;
infoTex.setText;
repaint;
}
}
}
if//变换两层砖块1的2种情况 {
if {
if
{
num_csh_game;
game_body[game_sign_y[0]][game_sign_x[0] - 2] = 1; game_body[game_sign_y[1]][game_sign_x[1]] = 1;
game_body[game_sign_y[2] - 1][game_sign_x[2] - 1] = 1; game_body[game_sign_y[3] - 1][game_sign_x[3] + 1] = 1; infoTex.setText;
repaint;
}
}
if {
if
{
num_csh_game;
game_body[game_sign_y[0]][game_sign_x[0] + 2] = 1;
game_body[game_sign_y[1] + 1][game_sign_x[1] + 1] = 1; game_body[game_sign_y[2]][game_sign_x[2]] = 1;
game_body[game_sign_y[3] + 1][game_sign_x[3] - 1] = 1; infoTex.setText;
repaint;
}
}
}
if//变换两层砖块2的2种情况 {
if {
if
{
num_csh_game; != != != != != !=
game_body[game_sign_y[0]][game_sign_x[0] + 2] = 1;
game_body[game_sign_y[1] - 1][game_sign_x[1] + 1] = 1; game_body[game_sign_y[2]][game_sign_x[2]] = 1;
game_body[game_sign_y[3] - 1][game_sign_x[3] - 1] = 1; infoTex.setText;
repaint;
}
}
if {
if
{
num_csh_game;
game_body[game_sign_y[0] + 1][game_sign_x[0] - 1] = 1; game_body[game_sign_y[1]][game_sign_x[1] - 2] = 1;
game_body[game_sign_y[2] + 1][game_sign_x[2] + 1] = 1; game_body[game_sign_y[3]][game_sign_x[3]] = 1;
infoTex.setText;
repaint;
}
}
}
}
public void num_csh_game//数组清零
{
for
{
for
{
if
{
game_body[i][j] = 2;
}
else
{
game_body[i][j] = 0;
}
}
} 1] != !=
}
public void num_csh_restart//重新开始时数组清零
{
for
{
for
{
game_body[i][j] = 0;
}
}
}
public void keyTyped{} 扩展:java俄罗斯方块代码 / java俄罗斯方块 / java经典编程300例
public void keyPressed
{
if == KeyEvent.VK_DOWN&&startSign == 1)//处理下键 {
this.down;
}
if == KeyEvent.VK_LEFT&&startSign == 1)//处理左键 {
this.left;
}
if == KeyEvent.VK_RIGHT&&startSign == 1)//处理右键 {
this.right;
}
if == KeyEvent.VK_UP&&startSign == 1)//处理上键转换 {
this.change_body;
}
if
{
infoTex.setText;
}
}
public void keyReleased{}
public void paint
{
g.setColor;
g.fill3DRect;
for
{
for
{
if
{
g.setColor;
g.fill3DRect,30,30,true);
}
if
{
g.setColor;
g.fill3DRect,30,30,true);
}
}
}
}
public void left//向左移动
{
int sign = 0;
dingwei;
for
{
if
{
sign = 1;
}
}
if
{
num_csh_game;
for
{
game_body[game_sign_y[k]][game_sign_x[k] - 1] = 1;
}
infoTex.setText;
repaint;
}
}
public void right//向右移动
{
int sign = 0;
dingwei;
for
{
if
{
sign = 1;
}
}
if
{
num_csh_game;
for
{
game_body[game_sign_y[k]][game_sign_x[k] + 1] = 1;
}
infoTex.setText;
repaint;
}
}
public void down//下落
{
int sign = 0;
dingwei;
for
{
if
{
sign = 1;
downSign = true;
changeColor;
cancelDW;
getScore;
if == false)
{
rand_block;
repaint;
}
}
} +
if
{
num_csh_game;
for
{
game_body[game_sign_y[k] + 1][game_sign_x[k]] = 1; }
infoTex.setText;
repaint;
}
}
public boolean game_over//判断游戏是否结束
{
int sign=0;
for
{
if
{
sign = 1;
}
}
if
{
infoTex.setText;
changeColor;
repaint;
startSign = 0;
timer return true;
}
else
return false;
}
public void getScore//满行消除方法
{
for
{
int sign = 0;
for
{
if
{
sign++;
}
}
if
{
gameScore += 100;
scoreTex.setText;
infoTex.setText;
for
{
for
{
game_body[j][k] = game_body[j - 1][k]; }
}
}
}
}
public void changeColor//给已经落下的块换色 {
downSign = false;
for
{
game_body[game_sign_y[k]][game_sign_x[k]] = 2; }
}
public void dingwei//确定其位置
{
int k = 0;
cancelDW;
for
{
for
{
if
{
game_sign_x[k] = j;
game_sign_y[k] = i;
k++;
}
}
}
}
public void cancelDW//将定位数组初始化 {
for
{
game_sign_x[k] = 0;
game_sign_y[k] = 0;
}
}
public void block1//长条
{
game_body[0][4] = 1;
game_body[1][4] = 1;
game_body[2][4] = 1;
game_body[3][4] = 1;
}
public void block2//正方形
{
game_body[3][4] = 1;
game_body[2][4] = 1;
game_body[3][5] = 1;
game_body[2][5] = 1;
}
public void block3//3加1 {
game_body[1][4] = 1; 扩展:java俄罗斯方块代码 / java俄
罗斯方块 / java经典编程300例
game_body[2][4] = 1;
game_body[3][4] = 1;
game_body[3][5] = 1;
}
public void block4//3加1 {
game_body[1][4] = 1;
game_body[2][4] = 1;
game_body[3][4] = 1;
game_body[2][5] = 1;
}
public void block5//3加1 {
game_body[1][4] = 1;
game_body[2][4] = 1;
game_body[3][4] = 1;
game_body[1][5] = 1;
}
public void block6//转折1
{
game_body[1][5] = 1;
game_body[2][5] = 1;
game_body[2][4] = 1;
game_body[3][4] = 1;
}
public void block7//转折2
{
game_body[1][4] = 1;
game_body[2][4] = 1;
game_body[2][5] = 1;
game_body[3][5] = 1;
}
}
//定时线程
class MyTimer extends Thread
{
Block myBlock;
public MyTimer
{
this.myBlock = myBlock;
}
public void run
{
while
{
try{
sleep*100); myBlock.down;
}
catch{}
}
}
}
扩展:java俄罗斯方块代码 / java俄罗斯方块 / java经典编程300例