一个俄罗斯方块的源代码Word文档下载推荐.docx
《一个俄罗斯方块的源代码Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《一个俄罗斯方块的源代码Word文档下载推荐.docx(20页珍藏版)》请在冰豆网上搜索。
{{0,0,0,0},{1,1,1,0},{0,1,0,0},{0,0,0,0}},
{{0,1,0,0},{1,1,0,0},{0,1,0,0},{0,0,0,0}},
{{1,0,0,0},{1,1,0,0},{0,1,0,0},{0,0,0,0}},
{{0,0,0,0},{0,1,1,0},{1,1,0,0},{0,0,0,0}},
{{0,1,0,0},{1,1,0,0},{1,0,0,0},{0,0,0,0}},
{{0,0,0,0},{1,1,0,0},{0,1,1,0},{0,0,0,0}},
{{1,0,0,0},{1,0,0,0},{1,1,0,0},{0,0,0,0}},
{{0,0,0,0},{1,1,1,0},{1,0,0,0},{0,0,0,0}},
{{1,1,0,0},{0,1,0,0},{0,1,0,0},{0,0,0,0}},
{{0,0,0,0},{0,0,1,0},{1,1,1,0},{0,0,0,0}},
{{0,1,0,0},{0,1,0,0},{1,1,0,0},{0,0,0,0}},
{{0,0,0,0},{1,0,0,0},{1,1,1,0},{0,0,0,0}},
{{1,1,0,0},{1,0,0,0},{1,0,0,0},{0,0,0,0}},
{{0,0,0,0},{1,1,1,0},{0,0,1,0},{0,0,0,0}},
};
unsignedback[22][14]={{1,1,0,0,0,0,0,0,0,0,0,0,1,1},
{1,1,0,0,0,0,0,0,0,0,0,0,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1}};
charShapeColor[7]={8,10,11,12,13,14,15};
charDigitalShape[10]={128+119,3,62,31,128+75,128+93,128+125,19,128+127,128+95};
charZodiacBack[11]={4,6,12,13,11,10,2,3,9,1,8};
charZodiacSoft[18][14]={{0,0,0,0,96,0,0,0,0,0,0,0,60,0},
{255,248,0,0,96,0,0,0,0,248,0,0,124,0},
{255,248,0,0,97,128,0,0,3,248,0,0,192,0},
{0,112,0,0,97,128,0,0,7,0,0,1,128,48},
{0,224,0,0,96,0,0,0,14,0,0,1,128,48},
{1,192,0,0,96,0,0,0,12,0,0,1,128,48},
{3,128,120,15,97,128,240,60,12,0,15,15,249,255},
{7,0,252,31,225,131,248,127,14,0,31,143,249,255},
{7,1,142,48,225,135,24,227,7,240,49,193,128,48},
{14,3,134,96,97,142,24,192,3,252,112,193,128,48},
{28,3,6,96,97,140,25,192,0,28,96,193,128,48},
{56,3,6,96,97,140,25,128,0,6,96,193,128,48},
{120,3,6,96,97,140,25,128,0,6,96,193,128,48},
{224,1,140,48,225,142,25,195,24,14,49,129,128,48},
{255,249,252,63,225,135,252,255,28,28,63,129,128,48},
{255,248,240,15,97,131,236,60,15,248,30,1,128,48},
{0,0,0,0,0,0,0,0,7,224,0,1,128,0}};
unsignedlongTotalMark=0;
unsignedintErasered=0,ETimes=0;
intSpeed=0;
intCEr=0;
intNumOfLev[5]={0,0,0,0,0};
intTimeDelay[10]={21,18,17,15,13,11,9,7,5,3};
charNewShape[2];
unsignedPerOnce[4];
voidinterrupt(*oldhandler)(__CPPARGS);
voidinterrupthandler(__CPPARGS)
++counter;
oldhandler();
}
voidDrawBackground()
//setlinestyle
voidDrawDigital(intx,inty,inta)
inti=7;
setcolor(((DigitalShape[a]>
>
i)&
1)*7+4);
//printf("
%d"
(DigitalShape[a]>
1);
i--;
line(x,y+1,x,y+15);
line(x+1,y+2,x+1,y+14);
line(x+2,y+3,x+2,y+13);
line(x,y+17,x,y+31);
line(x+1,y+18,x+1,y+30);
line(x+2,y+19,x+2,y+29);
line(x+1,y,x+16,y);
line(x+2,y+1,x+15,y+1);
line(x+3,y+2,x+14,y+2);
line(x+2,y+15,x+15,y+15);
line(x+1,y+16,x+16,y+16);
line(x+2,y+17,x+15,y+17);
line(x+3,y+30,x+14,y+30);
line(x+2,y+31,x+15,y+31);
line(x+1,y+32,x+16,y+32);
line(x+15,y+3,x+15,y+13);
line(x+16,y+2,x+16,y+14);
line(x+17,y+1,x+17,y+15);
line(x+15,y+19,x+15,y+29);
line(x+16,y+18,x+16,y+30);
line(x+17,y+17,x+17,y+31);
voidArtClear()
for(inti=480;
i>
=0;
i-=2)
setcolor(3);
line(0,i-6,639,i-6);
setcolor(9);
line(0,i-4,639,i-4);
setcolor
(1);
line(0,i-2,639,i-2);
setcolor(getbkcolor());
line(0,i,639,i);
delay
(1);
for(i=1;
i<
480;
i+=2)
line(0,i+6,639,i+6);
line(0,i+4,639,i+4);
line(0,i+2,639,i+2);
voidend()
for(intj=0;
j<
4;
j++)
for(inti=j;
i+=4)
line(0,i+8,639,i+8);
delay(5);
setcolor(YELLOW);
outtextxy(260,200,"
[GameOver]"
);
gotoxy(14,16);
printf("
ThisfreewareiswrittenbyDaniel.QuZodiacSoft2000"
gotoxy(12,17);
Pleasee-mailtoswami@orvisitmyhomepageat"
gotoxy(12,18);
ifyouhavequestion."
gotoxy(14,20);
Iwillsoonprovidesomethingnew,pleasewait..."
gotoxy(14,22);
Weholdthesetruthstobeself-evident,thatallcodes"
gotoxy(12,23);
arecreatedFREE."
getch();
clrscr();
closegraph();
exit(0);
voidShowTitle()
intgdriver=DETECT,gmode,errorcode,i,j,k;
initgraph(&
gdriver,&
gmode,"
"
errorcode=graphresult();
if(errorcode!
=grOk)
Graphicserror:
%s\n\007"
grapherrormsg(errorcode));
exit
(1);
setbkcolor(9);
//Thislineneedstobechanged
for(i=0;
11;
i++)
setcolor(ZodiacBack[i]);
line(200,i*8+100,440,i*8+100);
delay(1000);
for(j=0;
17;
setcolor(ZodiacBack[(i+j)%16]);
delay(4);
18;
14;
for(k=7;
k>
k--)
if((ZodiacSoft[j][i]>
k)&
1)
putpixel(i*8-k+271,j+122,14);
delay(10);
for(j=17;
j>
j--)
putpixel(i*8-k+271,158-j,5);
setcolor(15);
outtextxy(295,171,"
Present"
ArtClear();
voidDrawShape(intx,inty,intcolor)
//if(x<
2||x>
12||y>
19)
//return;
setcolor(color);
/*line(x<
<
4,y<
4,x<
4,(y<
4)+14);
line(x<
4)+14,(x<
4)+14,(y<
line((x<
4)+14,y*16);
4)+14,y<
4,y*16);
4)+1,y<
4,(x<
4)+1,(y<
4)+13,(x<
4)+13);
4)+13,(y<
4)+1);
4)+1,x<
*/
for(inti=0;
15;
4)+i,(x<
4)+i);
setcolor(8);
4)+15,(y<
4)+1,(x<
4)+15);
4)+15,(x<
setcolor(color-8);
4)+2,(y<
4)+2,(x<
4)+12,(y<
4)+2);
4)+12);
voidDrawNull(intx,inty)
16;
voidshow(intx,inty,intCurrentShape,intStatus)
inttemp;
20;
for(intj=2;
12;
if(back[i][j]==1)
DrawShape(6+j,4+i,8);
else
DrawNull(6+j,4+i);
}//nomatterwhatthestatusbe,Iwilldrawthebackground
for(intl=0;
l<
l++)
for(intp=0;
p<
p++)
if(l+x<
2||x+l>
11||p+y>
continue;
//if(shape[CurrentShape][Status][p][l]+back[y+p][x+l]==1)
//DrawShape(3+l+x,3+p+y,8+CurrentShape);
//else
//cout<
’O’;
//DrawNull(3+j,3+i);
if(shape[CurrentShape][Status][p][l]==1)
DrawShape(6+l+x,4+p+y,ShapeColor[CurrentShape]);
if(back[y+p][x+l]==1)
DrawShape(6+l+x,4+p+y,8);
voidDrawScore()
inttemp=TotalMark;
7;
DrawDigital(477-i*20,65,temp%10);
temp/=10;
temp=Erasered;
DrawDigital(491-i*20,111,temp%10);
if(Erasered==0)
return;
5;
setfillstyle(1,8);
bar(378,163+i*14,508,170+i*14);
setfillstyle(1,5);
bar(378,163+i*14,378+130*NumOfLev[i]/ETimes,170+i*14);
DrawDigital(466,293,Speed);
intCreateNewShape()
NewShape[1]=NewShape[0];
NewShape[0]=rand()%7;
setfillstyle(1,0);
bar(447,240,514,288);
if(shape[NewShape[0]][0][p][l]==1)
DrawShape(28+l,15+p,ShapeColor[7]);
returnNewShape[1];
intPossible(intx,inty,intCurrentShape,intStatus)
if(shape[CurrentShape][Status][i][j]+back[y+i][x+j]==2)
//thislinecanalsowriteasthefollowingtype:
//if(shape[CurrentShape][Status][i][j]&
&
back[y+i][x+j])
return0;
return1;
voidGoLeft(int&
x,int&
y,int&
CurrentShape,int&
Status)
if(Possible(x-1,y,CurrentShape,Status))
x--;
show(x,y,CurrentShape,Status);
voidGoRight(int&