資源描述:
《俄羅斯方塊和貪吃蛇的C語言源程序.doc》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、俄羅斯方塊和貪吃蛇的C語言源程序剛剛在群里聽某些人說發(fā)上來可以拿獎金,于是我就發(fā)了~~~臉皮比較厚,大家見笑了~~雖然寫的沒有網(wǎng)上現(xiàn)成的那些好,但是這些100%是自己寫的,因為是寫著玩的,所以就沒有優(yōu)化,也沒有用什么復雜的技術(shù),但是這樣的程序反而更容易看懂~編譯環(huán)境是古老的turboc2.0,喜歡dos編程的朋友可以拿來消遣一下。嘿嘿嘿嘿~附件是源文件和編譯好的文件~俄羅斯方塊-------------------------#include"graphics.h"#include"stdio.h"#include"
2、stdlib.h"#include"string.h"#include"bios.h"#include"time.h"#include"stdlib.h"#include"dos.h"#defineVK_ESC0x11b#defineVK_UP0x4800#defineVK_DOWN0x5000#defineVK_LEFT0x4b00#defineVK_RIGHT0x4d00#defineTIMER0x1c#defineSEC(N)N*18.8typedefbox[4][4];FILE*fp;intspace[26]
3、[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()
4、;voidDrawBox();voidCreateBar(inti,intj,box*type,intvalue);voidSetTimer(voidinterrupt(*theProc)());voidKillTimer();voidinterruptProc();voidinterrupt(*oldtimer)();voidOneStep();intIsFall();voidCheckState();voidClearLine(intLine);voidMoveLeft();voidMoveRight();voi
5、dChangeBar();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
6、=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(count>SEC(0.5)){count=0;OneStep();}if(bioskey(1)){key=bioskey(0);if(key==VK_ESC){break;
7、}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(score>higher)higher=score;WriteHigh();return0;}voidSetScreen(){in
8、tGraphDriver=DETECT;intGraphMode=VGAHI;initgraph(&GraphDriver,&GraphMode,"");setbkcolor(LIGHTMAGENTA);}voidSetValue(){inti,j;for(i=0;i<24;i++)for(j=0;j<16;j++)space[j]=0;}vo