dataio.java
来自「J2SE版的俄罗斯方块。SWING界面.有分数记录功能」· Java 代码 · 共 57 行
JAVA
57 行
public class DataIO
//数据处理类
{
private BackGround BG;
private Box box;
public DataIO(BackGround BG,Box box)
{
this.BG=BG;
this.box=box;
}
public void WriteBoxToGround()
{
int temp;
for(int y=box.y;y<box.y+4;y++)
for(int x=box.x;x<box.x+4;x++)
{
temp=x;
if(temp>10)temp=10;
if(BG.ground[y][temp]==5)
BG.ground[y][temp]=3;
}
//把背景中的临时块转化为死块
}
public void Del(int dy)
{
int buff[][]=new int[26][12];
int temp;
for(int y=3;y<dy;y++)
for(int x=1;x<11;x++)
{
temp=y;
//if(temp>=22)temp=21;
buff[temp][x]=BG.ground[temp][x];
}
for(int y=3;y<dy;y++)
for(int x=1;x<11;x++)
{
temp=y;
//if(temp>=21)temp=21;
BG.ground[temp+1][x]=buff[temp][x];
}
}
public void addscore(int l)
{
if(l==0)return;
if(l==1)box.score=box.score+10;
else
{
box.score=box.score+(l*l-1)*10;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?