c语言编俄罗斯方块有注释,C语言学习1年-俄罗斯方块(无注释)

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

#include 

#include 

#include 

#include 

#include 

int randtmp=3,i,j,p,q,fx,fy,s,t,c,r,dltm,begin=0,fq,k,a,sj,score=0;

int dla=32000;

int nx[5],ny[5],h[5],m[25];

int x[8][4]={

0,0,0,0,

0,-2,-1,0,

0,0,1,2,

0,0,0,0,

0,-1,0,1,

0,0,1,1,

0,-1,0,1,

0,-1,0,1,

};        int y[8][4]={

0,0,0,0,

0,0,0,1,

0,1,0,0,

0,1,2,3,

0,0,1,0,

0,1,0,1,

0,1,1,0,

0,0,1,1,

};

display(int i,int t){

for(j=0;j<4;j++){

textcolor(i);

q=fy+y[i][j];

p=fx+x[i][j];

gotoxy(p,q); putch(t);

}

}

turn(){

for(j=1;j<4;j++){

c=x[i][j]; x[i][j]=-y[i][j]; y[i][j]=c;

}

test();

if (s==0) return;

for (j=1;j<4;j++){

c=y[i][j]; y[i][j]=-x[i][j]; x[i][j]=c;

}

}

full(){

int fj=0,yj;

for(j=0;j<4;j++){

yj=fy+y[i][j];

m[yj]++;

if(m[yj]==12)  fj=1;

}

if (fj==1) {kill();}

}

kill(){

char tm[2],tf,z,k=0;

for(z=23;z>4;z--){

if (m[z]==12){k++;

for(q=z-1;q>4;q--){

for (p=11;p<=22;p++){

gettext(p,q,p,q,&tm);

tf=tm[0];

if(tf==32){

gotoxy(p,q+1);

printf(" ");

}else{gotoxy(p,q+1);putch(219);}

}

m[q+1]=m[q];

} z++;

}

}

if(k==1) score++;

if(k==2) score+=3;

if(k==3) score+=7;

if(k>=4) score+=13;

}

test(){

char tmp[2];

s=0;

for(j=0;j<4;j++){

q=fy+y[i][j];

p=fx+x[i][j];

gettext(p,q,p,q,&tmp);

if(tmp[0]!=32) s=1;

}

}

left(){

int ox;

display(i,32);

ox=fx;

fx--;

test();

if(s==1) fx=ox;

display(i,219);

}

right(){

int ox;

t=32;

display(i,t);

ox=fx;

fx++;

test();

if(s==1) fx=ox;

t=219;

display(i,t);

}

inkey(){

int k;

if(kbhit()){

k=getch();

if(k==27) exit(0);

if(k==0){

k=getch();

switch(k){

case 77: right(); break;

case 75: left();  break;

case 72: turn();

break;

case 80: dla=8888;           break;

}

}

}

}

levelchooser(){

int level;

printf("\n\n\n\n\n\nWelcome Please:");

printf("\nINPUT LEVEL[Difficult=1 Normal=2 Easy=3]:");

scanf("%d",&level);

if(level<=1){dla=20000;dltm=dla;}

if(level==1){dla=20000;dltm=dla;}

if(level==2){dla=40000;dltm=dla;}

if(level==3){dla=60000;dltm=dla;}

if(level>=3){dla=60000;dltm=dla;}

clrscr();

begin=1;

}

over(){

int c,a;

textcolor(3);

for(i=1;i<=24;i++){

for(c=1;c<=40;c++){

textcolor(i);

delay(3200);

gotoxy(c,i);

putch(219);

}

}

for(a=1;a<=24;a++){

gotoxy(5,a);

delay(32000);

for(c=1;c<=40;c++){

textcolor©;

gotoxy(c,a);

putch(219);

}

}

delay(32000);

exit(0);

}

func(){

while(1){

i=randtmp;

randtmp=rand()%7+1;

fx=9;fy=2;

gotoxy(1,2);printf("NEXT:");

display(randtmp,219);

fx=16;fy=5;

while(1){

test();

if((s==1) && (fy==5)) {

over();

}

inkey();

display(i,219);

delay(dla);delay(dla);delay(dla);

display(i,32); fy++; test();gotoxy(12,1);printf("score=%d",score);

if(s==1){

fy--;

display(i,219);

full();

fx=9;fy=2;

display(randtmp,32);

fy=5;

fx=16;

dla=dltm;

break;

}

}

}

}

box(){

gotoxy(11,12);

for(i=4;i<=23;i++){

m[i]=0;textcolor(i);

gotoxy(10,i);

putch(219);

gotoxy(23,i);

putch(219);

}

for(i=10;i<=23;i++){

textcolor(i);

gotoxy(i,24);

putch(219);

}

fx=16;

fy=5;

}

main(){

int e1,e2;

union REGS r;

textmode(C40);

clrscr();

levelchooser();

randomize();

r.x.ax=0x0100;

r.x.cx=0x2000;

int86(0x10,&r,&r);

box();

func();

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值