小游戏俄罗斯方块代码

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

东西绝对不多说,直接看!看了拷贝就懂了!!,直接可以拷贝下面的东西,然后记得把那个BLOCK的名字改成你自己的类名,这个很关键哦,不然是错的可别怪我,呵呵~~

import .*;

import .*;

import .*;

import .*;

import .*;

public class Block extends JPanel implements ActionListener,KeyListenerddActionListener(this);

but[i].addKeyListener(this);

but[i].setBounds(360,(240 + 30 * i),160,25);

}

add(scoreLab);

add(scoreTex);

add(speedLab);

add(speedTex);

add(infoLab);

add(infoTex);

add(scoreLab);

(320,15,30,20);

(360,15,160,20);

;

(320,45,30,20);

(360,45,160,20);

;

but[1].setEnabled(false);

but[4].setEnabled(false);

(320,75,30,20);

(360,75,160,20);

;

(360,360,160,25);

(this);

(this);

(this);

(this);

(this);

num_csh_game();

rand_block();

}

public void actionPerformed(ActionEvent e) {

if() == but[0])etEnabled(false);

but[1].setEnabled(true);

but[4].setEnabled(true);

();

}

if() == but[1]||() == mi0)etEnabled(true);

but[1].setEnabled(false);

but[4].setEnabled(false);

}

if() == but[2])//降低级数

{

("降低级数!");

speedMark--;

if(speedMark <= 1)

{

speedMark = 1;

("已经是最低级数!");

}

(speedMark + "");

}

if() == but[3])//提高级数

{

("提高级数!");

speedMark++;

if(speedMark >= 9)

{

speedMark = 9;

("已经是最高级数!");

}

(speedMark + "");

}

if() == but[4])//游戏暂停

{

(noStop);

(but[4]);

("游戏暂停!");

();

}

if() == noStop)//取消暂停

{

(noStop);

(but[4]);

("继续游戏!");

();

}

if() == but[5]||() == mi1)//退出游戏

{

();

}

if() == mi1_0)//退出游戏

{

dlg_1 = new JDialog(jf,"关于");

try{

FileInputStream io = new FileInputStream("resource/");//得到路径byte a[] = new byte[()];

(a);

();

String str = new String(a);

(str);

}

catch(Exception g){}

(false);

(dlg_1_text);

();

(false);

(200, 120);

(400, 240);

();

}

}

public void rand_block()//随机产生砖块

{

int num;

num = (int)() * 6) + 1;//产生0~6之间的随机数

blockNumber = num;

switch(blockNumber)

{

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;

}

相关文档
最新文档