俄罗斯方块和贪吃蛇的C语言源程序刚刚在群里听某些人说发上来可以拿奖金,于是我就发了~~~脸皮比较厚,大家见笑了~~虽然写的没有网上现成的那些好,但是这些100%是自己写的,因为是写着玩的,所以就没有优化,也没有用什么复杂的技术,但是这样的程序反而更容易看懂~编译环境是古老的turboc2.0,喜欢dos编程的朋友可以拿来消遣一下。嘿嘿嘿嘿~附件是源文件和编译好的文件~俄罗斯方块-------------------------#includegraphics.h#includestdio.h#includestdlib.h#includestring.h#includebios.h#includetime.h#includestdlib.h#includedos.h#defineVK_ESC0x11b#defineVK_UP0x4800#defineVK_DOWN0x5000#defineVK_LEFT0x4b00#defineVK_RIGHT0x4d00#defineTIMER0x1c#defineSEC(N)N*18.8typedefbox[4][4];FILE*fp;intspace[26][18];boxbar1[2],bar2[1],bar3[4],bar4[2],bar5[2],bar6[4],bar7[4];floatcount;intnexttype,nextvalue;intovered;intscore,higher;charscoretext[50],highscore[50];struct{inti;intj;box*t;intv;}cur_bar;voidSetScreen();voidSetValue();voidDraw();voidSetBox();voidDrawBack();voidDrawBox();voidCreateBar(inti,intj,box*type,intvalue);voidSetTimer(voidinterrupt(*theProc)());voidKillTimer();voidinterruptProc();voidinterrupt(*oldtimer)();voidOneStep();intIsFall();voidCheckState();voidClearLine(intLine);voidMoveLeft();voidMoveRight();voidChangeBar();voidShowScore();voidShowNextWindow();voidReadHigh();voidWriteHigh();intmain(){intkey;count=0;overed=0;score=0;ReadHigh();randomize();oldtimer=getvect(TIMER);SetBox();SetScreen();DrawBack();Draw();CreateBar(0,5,bar3,2);nexttype=random(7)+1;nextvalue=0;ShowNextWindow();SetTimer(Proc);setcolor(BLUE);outtextxy(520,60,YOURSCORE);outtextxy(520,80,0);outtextxy(520,100,HIGHSCORE);outtextxy(520,120,highscore);while(1){if(countSEC(0.5)){count=0;OneStep();}if(bioskey(1)){key=bioskey(0);if(key==VK_ESC){break;}if(!overed)switch(key){caseVK_LEFT:MoveLeft();break;caseVK_RIGHT:MoveRight();break;caseVK_UP:ChangeBar();break;caseVK_DOWN:OneStep();CheckState();break;}else{break;}}}closegraph();KillTimer();if(scorehigher)higher=score;WriteHigh();return0;}voidSetScreen(){intGraphDriver=DETECT;intGraphMode=VGAHI;initgraph(&GraphDriver,&GraphMode,);setbkcolor(LIGHTMAGENTA);}voidSetValue(){inti,j;for(i=0;i24;i++)for(j=0;j16;j++)space[j]=0;}voidDraw(){inti,j;setfillstyle(SOLID_FILL,LIGHTBLUE);setcolor(BLACK);for(i=0;i24;i++)for(j=0;j16;j++){if(space[j]){bar(160+j*20,i*20,160+j*20+20,i*20+20);rectangle(160+j*20,i*20,160+j*20+20,i*20+20);}}}voidSetBox(){inti,j,k;for(i=0;i2;i++)for(j=0;j4;j++)for(k=0;k4;k++)bar1[j][k]=0;bar1[0][0][1]=1;bar1[0][1][1]=1;bar1[0][2][1]=1;bar1[0][3][1]=1;bar1[1][2][0]=1;bar1[1][2][1]=1;bar1[1][2][2]=1;bar1[1][2][3]=1;for(i=0;i1;i++)for(j=0;j4;j++)for(k=0;k4;k++)bar2[j][k]=0;bar2[0][1][1]=1;bar2[0][1][2]=1;bar2[0][2][1]=1;bar2[0][2][2]=1;for(i=0;i4;i++)for(j=0;j4;j++)for(k=0;k4;k++)bar3[j][k]=0;bar3[0][1][1]=1;bar3[0][2][0]=1;bar3[0][2][1]=1;bar3[0][3][1]=1;bar3[1][1][1]=1;bar3[1][2][0]=1;bar3[1][2][1]=1;bar3[1][2][2]=1;bar3[2][1][1]=1;bar3[2][2][1]=1;bar3[2][2][2]=1;bar3[2][3][1]=1;bar3[3][2][0]=1;bar3[3][2][1]=1;bar3[3][2][2]=1;bar3[3][3][1]=1;for(i=0;i2;i++)for(j=0;j4;j++)for(k=0;k4;k++)bar4[j][k]=0;bar4[0][1][2]=1;bar4[0][2][1]=1;bar4[0][2][2]=1;bar4[0][3][1]=1;bar4[1][2][1]=1;bar4[1][2][2]=1;bar4[1][3][2]=1;bar4[1][3][3]=1;for(i=0;i2;i++)for(j=0;j4;j++)for(k=0;k4;k++)bar5[j][k]=0;bar5[0][1][1]=1;bar5[0][2][1]=1;bar5[0][2][2]=1;bar5[0][3][2]=1;bar5[1][3][1]=1;bar5[1][2][2]=1;bar5[1][2][3]=1;bar5[1][3][2]=1;for(i=0;i4;i++)for(j=0;j4;j++)for(k=0;k4;k++)bar6[j][k]=0;bar6[0][1][1]=1;bar6[0][1][2]=1;bar6[0][2][2]=1;bar6[0][3][2]=1;bar6[1][2][1]=1;bar6[1][2][2]=1;bar6[1][2][3]=1;bar6[1][3][1]=1;bar6[2][1][1]=1;bar6[2][2][1]=1;bar6[2][3][1]=1;bar6[2][3][2]=1;bar6[3][3][0]=1;bar6[3][3][1]=1;bar6[3][3][2]=1;bar6[3][2][2]=1;for(i=0;i4;i++)for(j=0;j4;j++)for(k=0;k4;k++)bar7[j][k]=0;bar7[0][1][1]=1;bar7[0][1][2]=1;bar7[0][2][1]=1;bar7[0][3][1]=1;bar7[1][2][1]=1;bar7[1][3][1]=1;bar7[1][3][2]=1;bar7[1][3][3]=1;bar7[2][1][2]=1;bar7[2][2][2]=1;bar7[2][3][2]=1;bar7[2][3][1]=1;bar7[3][2][0]=1;bar7[3][2][1]=1;bar7[3][2][2]=1;bar7[3][3][2]=1;}voidCreateBar(inti,intj,box*type,intvalue){while(bioskey(1))bioskey(0);cur_bar.i=i;cur_bar.j=j;cur_bar.t=type;cur_bar.v=value;DrawBox();}voidDrawBox(){inti,j;setfillstyle(SOLID_FILL,LIGHTBLUE);setcolor(BLACK);for(i=0;i4;i++)for(j=0;j4;j++){if((cur_bar.t)[cur_bar.v][j]){bar(160+(cur_bar.j*20)+j*20,(cur_bar.i*20)+i*20,160+(cur_bar.j*20)+j*20+20,(cur_bar.i*20)+i*20+20);rectangle(160+(cur_bar.j*20)+j*20,(cur_bar.i*20)+i*20,160+(cur_bar.j*20)+j*20+20,(cur_bar.i*20)+i*20+20);}}setfillstyle(SOLID_FILL,YELLOW);for(i=1;i4;i++)for(j=0;j4;j++){if((cur_bar.t[cur_bar.v][j])&&(cur_bar.i0)&&(!(cur_bar.t)[cur_bar.v][i-1][j])&&(!space[cur_bar.i+i-1][cur_bar.j+j])){if(j+cur_bar.j0||j+cur_bar.j15)setfillstyle(SOLID_FILL,LIGHTMAGENTA);bar(160+(cur_bar.j*20)+j*20,(cur_bar.i*20)+(i-1)*20,160+(cur_bar.j*20)+j*20+20,(cur_bar.i*20)+(i-1)*20+20);rectangle(160+(cur_bar.j*20)+j*20,(cur_bar.i*20)+(i-1)*20,160+(cur_bar.j*20)+j*20+20,(cur_bar.i*20)+(i-1)*20+20);if(j+cur_bar.j0||j+cur_bar.j15)setfillstyle(SOLID_FILL,YELLOW);}}i=0;for(j=0;j4;j++){if((cur_bar.t[cur_bar.v][j])&&(cur_bar.i0)&&(!space[cur_bar.i+i-1][cur_bar.j+j])){if(j+cur_bar.j0||j+cur_bar.j15)