签到

05月11日
尚未签到

共有回帖数 0

    做月子

    等级:
    C语言学习1年-俄罗斯方块(无注释)
    #include stdio.h
    #include stdlib.h
    #include math.h
    #include conio.h
    #include dos.h
    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;j4;j++){
       textcolor(i);
       q=fy+y[j];
       p=fx+x[j];
       gotoxy(p,q); putch(t);
     }
    }
    turn(){
     for(j=1;j4;j++){
       c=x[j]; x[j]=-y[j]; y[j]=c;
     }
     test();
     if (s==0) return;
     for (j=1;j4;j++){
       c=y[j]; y[j]=-x[j]; x[j]=c;
     }
    }
    full(){
     int fj=0,yj;
     for(j=0;j4;j++){
       yj=fy+y[j];
       m[yj]++;
       if(m[yj]==12)  fj=1;
     }
     if (fj==1) {kill();}
    }
    kill(){
     char tm[2],tf,z,k=0;
     for(z=23;z4;z--){
       if (m[z]==12){k++;
         for(q=z-1;q4;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;j4;j++){
       q=fy+y[j];
       p=fx+x[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("nnnnnnWelcome 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=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();
    }

    楼主 2016-01-15 16:20 回复

共有回帖数 0
  • 回 帖
  • 表情 图片 视频
  • 发表

登录直线网账号

Copyright © 2010~2015 直线网 版权所有,All Rights Reserved.沪ICP备10039589号 意见反馈 | 关于直线 | 版权声明 | 会员须知