C语言俄罗斯方块游戏源代码Word格式文档下载.docx
- 文档编号:14321283
- 上传时间:2022-10-22
- 格式:DOCX
- 页数:17
- 大小:57.86KB
C语言俄罗斯方块游戏源代码Word格式文档下载.docx
《C语言俄罗斯方块游戏源代码Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《C语言俄罗斯方块游戏源代码Word格式文档下载.docx(17页珍藏版)》请在冰豆网上搜索。
{{1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0},
{0,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0},
{0,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0},
{1,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0}},
{{1,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0},
{0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0},
{1,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0},
{0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0}},
{{0,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0},
{1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0},
{0,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0},
{1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0}},
{{1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0},
{1,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0},
{1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0},
{0,1,0,0,0,1,0,0,1,1,0,0,0,0,0,0}},
{{0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0},
{1,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0},
{1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0},
{1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0}},
{{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}};
intb[4][4];
main(intargc,char*argv[])
{
if(argc!
=1)
if(argv[1]!
="
"
)
Heng=atoi(argv[1]);
if(argv[2]!
Shu=atoi(argv[2]);
}
Init();
/*初始化界面*/
PreAct=random(8);
/*取得当前的方块*/
for(;
;
)/*以下是游戏流程*/
NextAct=random(8);
/*取得下一个方块*/
DrawNext
(1);
/*画出下一个方块*/
Act=PreAct;
if(Heng%2==0)ActH=Heng/2;
elseActH=(Heng-1)/2;
ActS=0;
/*方块开始从游戏空间的中间下落*/
Staus=0;
/*取开始的状态*/
NoPass=CAN;
/*物体可以下落*/
Give();
Display(Act+1);
/*显示当前的方块,每种方块的颜色不同*/
GoOn();
/*游戏的算法精髓所在*/
PreAct=NextAct;
/*方块下落完毕,取得下一个方块*/
DrawNext(0);
voidInit()
intGraphDriver=DETECT,GraphMode;
registerbgidriver(EGAVGA_driver);
initgraph(&
GraphDriver,&
GraphMode,"
);
if(kbhit())Sounds=CANNOT;
setcolor
(1);
OutTextXY(10,10,"
Tetris"
OutTextXY(30,30,"
Version2.0"
OutTextXY(10,120,"
Help:
OutTextXY(20,140,"
+:
Faster"
OutTextXY(20,160,"
-:
Slower"
OutTextXY(20,180,"
Esc:
Quit"
OutTextXY(20,200,"
F1:
Help"
OutTextXY(10,310,"
Copyright(c)1998.2.22"
OutTextXY(10,320,"
ByMr.Unique"
outtextxy(10,250,"
Score:
00000"
rectangle(BeginH-3,BeginS-3,BeginH+Heng*(Wid+2)+2,BeginS+Shu*(Wid+2)+2);
rectangle(BeginH-5,BeginS-5,BeginH+Heng*(Wid+2)+4,BeginS+Shu*(Wid+2)+4);
rectangle(BeginH+(Heng+4)*(Wid+2)-2,BeginS+10,BeginH+(Heng+8)*(Wid+2)+2,BeginS+12+4*(Wid+2));
for(i=0;
i<
MAX;
i++)
for(j=0;
j<
j++)
{Position[i][j]=1;
middle[i][j]=-1;
}
Heng;
Shu;
Position[i][j]=0;
DrawBox(i,j,0);
randomize();
voidGoOn()
{
)
Seconds+=0.2;
/*控制方块的下落速度*/
if(Seconds>
=Delays)
Down();
Seconds=0;
if(NoPass==BOTTOM)
DetectFill();
middle[ActH][ActS]=Act;
if(ActS==0)
Fail();
return;
if(kbhit())
Select();
voidDown()/*方块下降*/
Display(0);
if(Touch(ActH,ActS,0,1)==CAN)
ActS++;
else
Display(Staus+1);
intTouch(intx,inty,intdx,intdy)
4;
Position[x+dx+i][y+dy+j]+=b[i][j];
if(Position[i][j]>
1)
NoPass=CANNOT;
Position[x+dx+i][y+dy+j]-=b[i][j];
middle[x+dx+i][y+dy+j]=Act;
if(NoPass==CANNOT&
&
dx==0&
dy==1)
Position[x+i][y+j]+=b[i][j];
NoPass=BOTTOM;
returnNoPass;
intGetKey(void)
intCh,Low,Hig;
Ch=bioskey(0);
Low=Ch&
0x00ff;
Hig=(Ch&
0xff00)>
>
8;
return(Low==0?
Hig+256:
Low);
voidSelect()
intOldStaus,acts=ActS;
switch(GetKey())
caseESC:
Quit();
break;
caseDOWN:
Seconds+=14500;
caseLEFT:
if(ActH>
0&
Touch(ActH,ActS,-1,0)==CAN)
{ActH--;
caseRIGHT:
if(ActH<
Heng&
Touch(ActH,ActS,1,0)==CAN)
{ActH++;
caseBLANK:
Display(0);
ksdown();
caseF1:
Help();
caseEQUAL:
caseADD:
if(Delays>
300)Delays-=100;
caseDEC:
if(Delays<
3000)Delays+=100;
casePAUSEP:
casePAUSEp:
getch();
caseSOUNDS:
caseSOUNDs:
if(Sounds==CAN)
Sounds=CANNOT;
Sounds=CAN;
caseUP:
if(Act==7)
while(acts<
Shu-1&
Position[ActH][acts]!
=1)
acts++;
Position[ActH][acts]=0;
DrawBox(ActH,acts,0);
acts=ActS;
OldStaus=Staus;
switch(Act)
case0:
case3:
case4:
if(Staus==1)Staus=0;
elseStaus=1;
case1:
case2:
case5:
case6:
if(Staus==3)Staus=0;
elseStaus+
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 俄罗斯方块 游戏 源代码