俄罗斯方块源代码Word文档下载推荐.docx
- 文档编号:22019979
- 上传时间:2023-02-02
- 格式:DOCX
- 页数:19
- 大小:18.21KB
俄罗斯方块源代码Word文档下载推荐.docx
《俄罗斯方块源代码Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《俄罗斯方块源代码Word文档下载推荐.docx(19页珍藏版)》请在冰豆网上搜索。
/*判断这点是否要画色格*/
structgezizhiwen[4][4];
structarray/*用来装物体的形状*/
inta[4][4];
structbossarray/*搞这么多层,其实是为了随机出物体和改变物体的方向有顺序*/
structarrayb[4];
}shape[7];
/*要控制的物体的形状*/
inta1[4][4]={{0,0,0,0},{0,1,0,0},{1,1,1,0},{0,0,0,0}};
inta2[4][4]={{0,1,0,0},{0,1,1,0},{0,1,0,0},{0,0,0,0}};
inta3[4][4]={{0,0,0,0},{1,1,1,0},{0,1,0,0},{0,0,0,0}};
inta4[4][4]={{0,1,0,0},{1,1,0,0},{0,1,0,0},{0,0,0,0}};
intb1[4][4]={{1,1,0,0},{0,1,1,0},{0,0,0,0},{0,0,0,0}};
intb2[4][4]={{0,1,0,0},{1,1,0,0},{1,0,0,0},{0,0,0,0}};
intb3[4][4]={{0,0,0,0},{0,1,1,0},{1,1,0,0},{0,0,0,0}};
intb4[4][4]={{0,1,0,0},{1,1,0,0},{1,0,0,0},{0,0,0,0}};
intc1[4][4]={{0,1,1,0},{1,1,0,0},{0,0,0,0},{0,0,0,0}};
intc2[4][4]={{1,0,0,0},{1,1,0,0},{0,1,0,0},{0,0,0,0}};
intc3[4][4]={{0,0,0,0},{1,1,0,0},{0,1,1,0},{0,0,0,0}};
intc4[4][4]={{0,1,0,0},{1,1,0,0},{1,0,0,0},{0,0,0,0}};
intd1[4][4]={{0,1,1,0},{0,0,1,0},{0,0,1,0},{0,0,0,0}};
intd2[4][4]={{0,0,0,0},{0,0,1,0},{1,1,1,0},{0,0,0,0}};
intd3[4][4]={{1,0,0,0},{1,0,0,0},{1,1,0,0},{0,0,0,0}};
intd4[4][4]={{1,1,1,0},{1,0,0,0},{0,0,0,0},{0,0,0,0}};
inte1[4][4]={{1,1,0,0},{1,0,0,0},{1,0,0,0},{0,0,0,0}};
inte2[4][4]={{1,1,1,0},{0,0,1,0},{0,0,0,0},{0,0,0,0}};
inte3[4][4]={{0,0,1,0},{0,0,1,0},{0,1,1,0},{0,0,0,0}};
inte4[4][4]={{0,0,0,0},{1,0,0,0},{1,1,1,0},{0,0,0,0}};
intf1[4][4]={{0,0,0,0},{1,1,1,1},{0,0,0,0},{0,0,0,0}};
intf2[4][4]={{0,1,0,0},{0,1,0,0},{0,1,0,0},{0,1,0,0}};
intf3[4][4]={{0,0,0,0},{1,1,1,1},{0,0,0,0},{0,0,0,0}};
intf4[4][4]={{0,1,0,0},{0,1,0,0},{0,1,0,0},{0,1,0,0}};
intg1[4][4]={{0,0,0,0},{0,1,1,0},{0,1,1,0},{0,0,0,0}};
intg2[4][4]={{0,0,0,0},{0,1,1,0},{0,1,1,0},{0,0,0,0}};
intg3[4][4]={{0,0,0,0},{0,1,1,0},{0,1,1,0},{0,0,0,0}};
intg4[4][4]={{0,0,0,0},{0,1,1,0},{0,1,1,0},{0,0,0,0}};
voidsetshape(inta[4][4],inttemp[4][4])/*把上面的数组的形状装到shape里*/
inti,j;
for(i=0;
i<
4;
i++)
for(j=0;
j<
j++)
a[i][j]=temp[i][j];
}
voidsetshape2()/*给shape给他形状*/
setshape(shape[0].b[0].a,a1);
setshape(shape[0].b[1].a,a2);
setshape(shape[0].b[2].a,a3);
setshape(shape[0].b[3].a,a4);
setshape(shape[1].b[0].a,b1);
setshape(shape[1].b[1].a,b2);
setshape(shape[1].b[2].a,b3);
setshape(shape[1].b[3].a,b4);
setshape(shape[2].b[0].a,c1);
setshape(shape[2].b[1].a,c2);
setshape(shape[2].b[2].a,c3);
setshape(shape[2].b[3].a,c4);
setshape(shape[3].b[0].a,d1);
setshape(shape[3].b[1].a,d2);
setshape(shape[3].b[2].a,d3);
setshape(shape[3].b[3].a,d4);
setshape(shape[4].b[0].a,e1);
setshape(shape[4].b[1].a,e2);
setshape(shape[4].b[2].a,e3);
setshape(shape[4].b[3].a,e4);
setshape(shape[5].b[0].a,f1);
setshape(shape[5].b[1].a,f2);
setshape(shape[5].b[2].a,f3);
setshape(shape[5].b[3].a,f1);
setshape(shape[6].b[0].a,g1);
setshape(shape[6].b[1].a,g2);
setshape(shape[6].b[2].a,g3);
setshape(shape[6].b[3].a,g4);
/*改变格子数组flag的值,使之能显示物体的形状*/
voidzhiwen_flag()
{
voidtemp1(inta[4][4]);
/*函数声明*/
intestimate_error();
voidend();
intk;
randomize();
k=random(6);
zhongkai=k;
/*保存当前的要下落的物体的形状信息*/
warcraft3=4;
/*还原状态的初值*/
switch(k)
case0:
temp1(shape[0].b[0].a);
break;
case1:
temp1(shape[1].b[0].a);
case2:
temp1(shape[2].b[0].a);
case3:
temp1(shape[3].b[0].a);
case4:
temp1(shape[4].b[0].a);
case5:
temp1(shape[5].b[0].a);
case6:
temp1(shape[6].b[0].a);
}
if(estimate_error())
end();
}
voidtemp1(inta[4][4])/*跟着zhiwen_flag函数,是他的小弟*/
inti,j;
for(i=0;
for(j=0;
j++)
{
if(a[i][j]==1)
zhiwen[i][j].flag=1;
else
zhiwen[i][j].flag=0;
}
voidzhiwenflag_enter()
warcraft3++;
temp1(shape[zhongkai].b[warcraft3%4].a);
/*这函数用来改变方框的gezi_control的值,为画方框做准备*/
voidchange()
inti,j,k,p;
for(k=0;
k<
k++)
for(p=0;
p<
p++)
if(zhiwen[k][p].flag==1)
for(i=0;
N;
for(j=0;
M;
if((zhiwen[k][p].x==wu[i][j].x)&
&
(zhiwen[k][p].y==wu[i][j].y))
wu[i][j].gezi_control=1;
voiddraw()/*画出图形*/
if(wu[i][j].flag==0)
setfillstyle(0,BLACK);
bar(wu[i][j].x,wu[i][j].y,wu[i][j].x+20,wu[i][j].y+20);
setcolor(BLACK);
rectangle(wu[i][j].x,wu[i][j].y,wu[i][j].x+20,wu[i][j].y+20);
if(wu[i][j].gezi_control==1)
{
setfillstyle(11,YELLOW);
bar(wu[i][j].x,wu[i][j].y,wu[i][j].x+20,wu[i][j].y+20);
setcolor(RED);
}
if(wu[i][j].flag)
voidwuzhiwen200910214117()/*给zhiwen数组给初值,位置是最上面的格子*/
zhiwen[i][j].x=wu[i][j+2].x;
zhiwen[i][j].y=wu[i][j+2].y;
zhiwen[i][j].flag=0;
voidcleargezi_control()/*物体下落后,把wu的gezi_control恢复原来的值*/
j++)
wu[i][j].gezi_control=0;
voidsetflag()/*下落的物本固定住*/
wu[i][j].flag=1;
inttmd()/*看格子的flag与方框的flag是否重复*/
if(zhiwen[k][p].flag==1)
for(i=0;
for(j=0;
if(wu[i][j].flag==1)
if((wu[i][j].x==zhiwen[k][p].x)&
(wu[i][j].y==zhiwen[k][p].y))
return
(1);
return(0);
intestimate_error()/*判断zhiwen数组下移后是否与方框的格子重复*/
if(tmd())
return
(1);
intisunder()/*判断是否到了低了*/
if((zhiwen[i][j].flag==1)&
(zhiwen[i][j].y==wu[N-1][1].y))
intturnleft_error()/*功能是判断向左时合不合理*/
if(zhiwen[i][j].flag==1)
if(zhiwen[i][j].x==wu[1][0].x-20)
return
(1);
intturnright_error()/*功能是判断向右时合不合理*/
if(zhiwen[i][j].x==wu[1][M-1].x+20)
voiddeleteline()/*删除一行!
妈呀终于到了最后一个函数了!
!
*/
voiddeleteline2(intwuzhiwen);
inti,j,sum=0;
for(j=0,sum=0;
sum+=wu[i][j].flag;
if(sum==M)
deleteline2(i);
draw();
sleep
(1);
voiddeleteline2(intwuzhiwen)/*wuzhiwen是所在行,此函数专为deleteline()服务*/
for(j=0;
wu[wuzhiwen][j].flag=0;
for(i=wuzhiwen-1;
i>
=0;
i--)
if(wu[i][j].flag==1)
wu[i][j].flag=0;
wu[i+1][j].flag=1;
voidend()
clrscr();
outtextxy(200,200,"
pressanykeytoexit!
"
);
getch();
exit
(1);
voidmain()
/*中间数据*/
intgraphdriver=DETECT,graphmode;
voidplaygame();
/*给point结构体数组给初值;
for(i=1,wu[0][0].x=200;
wu[0][i].x=wu[0][i-1].x+20;
for(i=1;
wu[i][j].x=wu[0][j].x;
for(i=1,wu[0][0].y=20;
wu[i][0].y=wu[i-1][0].y+20;
for(j=1;
wu[i][j].y=wu[i][0].y;
wu[i][j].flag=0;
setshape2();
/*给每一个形状初值*/
wuzhiwen200910214117();
/*给zhiwen数组给初值*/
zhiwen_flag();
/*给格子数组初值*/
/*图形驱动*/
initgraph(&
graphdriver,&
graphmode,"
setcolor(YELLOW);
outtextxy(10,40,"
writer:
wuzhiwen"
outtextxy(10,60,"
number:
200910214117"
outtextxy(10,80,"
finishin2010-6-29"
outtextxy(10,100,"
from:
zhongkai_school"
outtextxy(10,120,"
class:
jiji091."
setcolor(WHITE);
outtextxy(10,200,"
howtoplay:
outtextxy(10,220,"
pressENTERtochange"
outtextxy(10,240,"
pressRIGHTorLEFT"
outtextxy(10,260,"
pressESCtoexit"
sleep(3);
rectangle(wu[0][0].x-5,wu[0][0].y-5,wu[N-1][M-1].x+25,wu[N-1][M-1].y+25);
playgame();
voidplaygame()
inti,j,k,p,i1,j1;
while
(1)
cleargezi_control();
change();
draw();
/*画图*/
sleep
(1);
/*格子数组的y值增加20。
for(i1=0;
i1<
i1++)
for(j1=0;
j1<
j1++)
zhiwen[i1][j1].y+=20;
if(isunder())/*当到了低时的那种情况*/
{
if(estimate_error())
{
zhiwen[i1][j1].y-=20;
cleargezi_control();
setflag();
deleteline();
wuzhiwen200910214117();
/*回到初始位置*/
/*给它形状*/
}
else
cleargezi_control();
}
elseif(estimate_error())
for(i1=0;
clea
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 俄罗斯方块 源代码
![提示](https://static.bdocx.com/images/bang_tan.gif)