C語言編程游戲代碼_第1頁
C語言編程游戲代碼_第2頁
C語言編程游戲代碼_第3頁
C語言編程游戲代碼_第4頁
C語言編程游戲代碼_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、#include#include#include#include#include#defineL1#defineLX15#defineLY4staticstructBLOCKintx0,y0,x1,y1,x2,y2,x3,y3;intcolor,next;intb=0,1,1,1,2,1,3,1,4,1,1,0,1,3,1,2,1,1,4,0,1,1,2,2,1,2,2,1,1,2,0,1,1,1,1,0,2,0,2,4,0,0,0,1,1,2,1,1,2,3,0,0,1,0,1,1,2,1,3,8,1,0,1,1,2,2,2,1,2,5,0,2,1,2,1,1,2,1,2,6,0,1,0,2

2、,1,1,1,0,3,9,0,1,1,1,1,2,2,2,3,10,1,1,1,2,2,1,2,0,3,7,1,0,1,1,1,2,2,2,7,12,0,1,1,1,2,1,2,0,7,13,0,0,1,2,1,1,1,0,7,14,0,1,0,2,1,1,2,1,7,11,0,2,1,2,1,1,1,0,5,16,0,1,1,1,2,2,2,1,5,17,1,0,1,1,1,2,2,0,5,18,0,0,0,1,1,11,2,1,5,15,0,1,1,1,1,0,2,1,6,2,0,0,1,1,2,1,1,1,0,6,21,0,1,1,2,1,1,2,1,6,22,1,0,1,1,1,2,2

3、,1,6,19;staticintd10=33000,3000,1600,1200,900,800,600,400,300,200;intLlevel,Lcurrent,Lnext,Lable,lx,ly,Lsum;unsignedLpoint;intLa1910,FLAG,sum;unsignedldelay;voidscrint(),datainit(),dispb(),eraseeb();voidthrow(),judge(),delayp(),move(0,note(0,show();intLdrop(),Ljudge(),nextb(),routejudge();main()char

4、c;datainit();Label=nextb();Label=Ldrop();while(1)delayp();if(Label!=0)Ljudge();Lable=nextb();ldelay-;if(ldelay=0)Label=Ldrop();ldelay=d0;if(FLAG!=0)break;while(getch()!=r);gotoxy(38,16);cputs(again?);c=getch();while(c!=n&c!=N)clscr();intnextb()if(La(bLnext.y0)(3+bLnext.x0)!=0|La(bLnext.y1)(3+bLnext.

5、x1)!=0|La(bLnext.y2)(3+bLnext.x2)!=0|La(bLnext.y3)3+bLnext.x3)!=0)FLAG=L;return(-1);eraseb(0,3,5,Lnext);Lcurrent=Lnext;lx=3;ly=0;Label=0;ldelay=d0;Lsum+;Lpoint+=1;Lnext=random(23);dispb(0,3,5,Lnext);textcolor(7);gotoxy(3,14);printf(%#5d,Lsum);gotoxy(3,17);printf(%#5d,Lpoint);return(0);voiddelayp()ch

6、arkey;if(kbhit()!=0)if(Laly+(bLcurrent.y0)lx+(bLcurrent.x0)=0&if(Laly+(bLcurrent.y0)lx+(bLcurrent.x0)=0&key=getch();move(key);if(key=)getch();voidmove(funkey)charfunkey;inttempcode;casek;if(lx+bcurrent.x00)if(Laly+(bLcurrent.y0)lx-1+(bLcurrent.x0)=0&La(ly+bcurrent.y1)(lx-1+bcurrent.x1=0&Laly+bcurren

7、t.y2)lx-1+bLcurrent.x2)=0&Laly+(bcurrent.y3)lx-1+(bLcurrent.x3)=0)eraseb(L,lx,lyLcurrent);lx-;dispb(L,lx,ly,Lcurrent);break;case0 x20;tempcode=bLcurrent.next;if(lx+btempcode.x0=0&lx+btempcode.x3=9&ly+btempcode.y1=19&ly+btempcode.y2=19)if(routejudge()!+-1)if(La+(btempcode.y0)lx+(btempcode.x0)=0&if(La

8、+(btempcode.y0)lx+(btempcode.x0)=0&Laly+(btempcode.y1)lx+(btempcode.x1)=0Laly+(btempcode.y2)lx+(btempcode.x2)=0Laly+(btempcode.y3)lx+(btempcode.x3)=0)eraseb(L,lx,ly,Lcurrent);Lcurrent=tempcode;dispb(L,lx,ly,Lcurrent);break;caseM;if(lx+bLcurrent.x39)Laly+(bLcurrent.y1)lx+(bLcurrent.x1)=0&Laly+(bLcurr

9、ent.y2)lx+(bLcurrent.x2)=0&Laly+(bLcurrent.y3)lx+(bLcurrent.x3)=0)eraseb(L,lx,ly,Lcurrent);lx+;disb(L,lx,ly,Lcurrent);break;casep;throw();break;case0 x1b;clrscr();exit(0);break;default:break;voidthrow()inttempy;tempy=ly;TOC o 1-5 h zwhile(ly+bLcurrent.y119&ly+bcurrent.y219&Laly+(bLcurrent.y0)lx+(bLc

10、urrent.x0)=0&Laly+(bLcurrent.y1)lx+(bLcurrent.x1)=0&Laly+(bLcurrent.y2)lx+(bLcurrent.x2)=0&Laly+(bLcurrent.y3)lx+(bLcurrent.x3)=0)ly+;ly-;eraseb(L,lx,tempy,Lcurrent);dispb(L,lx,ly,Lcurrent);Laly+bLcurrent.y0)lx+(bcurrent.x0)=Laly+bLcurrent.y1)lx+(bcurrent.x1)=Laly+bLcurrent.y2)lx+(bcurrent.x2)=Laly+

11、bLcurrent.y3)lx+(bcurrent.x3)=bLcurrent.color;Label=-1;introutejudge()inti,j;for(i=0;i3;i+)for(j=0;j=18|ly+bLcurrent.y2=18Laly+bLcurrent.y0)lx+(bcurrent.x0)=3;Laly+bLcurrent.y1)lx+(bcurrent.x1)=1;Laly+bLcurrent.y2)lx+(bcurrent.x2)=5;Laly+bLcurrent.y3)lx+(bcurrent.x3)=bLcurrent.color;return(-1);if(La

12、(ly+1+(bLcurrent.y0)lx+(bLcurrent.x0)!=0|La(ly+1+(bLcurrent.y1)lx+(bLcurrent.x1)!=0|La(ly+1+(bLcurrent.y2)lx+(bLcurrent.x2)!=0|La(ly+1+(bLcurrent.y3)lx+(bLcurrent.x3)!=0)Laly+bLcurrent.y0)lx+(bcurrent.x0)=Laly+bLcurrent.y1)lx+(bcurrent.x1)=0BLaly+bLcurrent.y2)lx+(bcurrent.x2)=Laly+bLcurrent.y3)lx+(b

13、current.x3)=bLcurrent.color)return(-1);eraseb(L,lx,ly,Lcurrent);dispb(L,lx,+ly,Lcurrent);return(0);intLjudge()inti,j,k,lines,f;staticintp5=0,1,3,6,10;lines=0;for(k=0;k18)continue;for(i=0;i0;i-)f+;break;if(f=0)movetext(LX,LY,LX+19,LY+ly+k-1,LX,LY+1);for(i=(ly+k);i0;i-)for(j=0;j10;j+)Laj=Lai-1j;for(j=

14、0;j10;j+)La0j=0;lines+;Lpoint+=plines*10;return(0);voidscrint()inti;charlft20;textbackground(1);clrscr();gotoxy(30,9);cputs(enteryourname);scanf(%s,lft);gotoxy(25,14);scanf(%s,lft);textbackground(0);clrscr();gotoxy(17,1);printf(%s,lft);gotoxy(5,3);puts(next);gotoxy(4,13);cputs(block);gotoxy(4,16);cp

15、uts(point);for(i=0;i19;i+)gotoxy(LX-2,LY+1);cputs(*);gotoxy(LX-2,LY+19);cputs(*);voiddatainit()inti,j;)for(i=0;i19;i+)for(j=0;j10;j+)Laj=0;Label=0;FLAG=0;ldelay=d0;Lsum=0;Lpoint=0;randomize();Lnext=random(23);voiddispb(LRflag,x,y,blockcode)intrealx,realy;if(LRflag=L)realx=LX+x*2;realy=LY+y;realx=x;r

16、aly=y;textcolor(bblockcode.color);gotoxy(realx+2*bblockcode.x0,realy+bblockcode.y0);cputs(*);gotoxy(realx+2*bblockcode.x1,realy+bblockcode.y1);cputs(*);gotoxy(realx+2*bblockcode.x2,realy+bblockcode.y2);cputs(*);gotoxy(realx+2*bblockcode.x3,realy+bblockcode.y3);cputs(*);voideraseb(LRflag,x,y,blockcode)intLRflag,x,y,blockcode;intrealx,realy;if(LRflag=L)realx=LX+x*2;realy=LY+y;elserealx=Lx+x*2;rea

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論