擋板球(小游戲)
《擋板球(小游戲)》由會(huì)員分享,可在線閱讀,更多相關(guān)《擋板球(小游戲)(5頁珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。
1、#include
2、 s2=8,s3=6,s4=4,s5=2,s6=0 }gamespeed; void chose() {int i; textmode(2); printf("\n\n\n\n Please Input The Speed You Want(from 1 to 6):"); scanf("%d",&i); switch(i) { case 1: gamespeed=s1;printf(" Thank You!! Wish You Have A Happy Day");for(;!kbhit();); break; case 2: gamespeed=s2;pri
3、ntf(" Thank You!! Wish You Have A Happy Day");for(;!kbhit();); break; case 3: gamespeed=s3;printf(" Thank You!! Wish You Have A Happy Day");for(;!kbhit();); break; case 4: gamespeed=s4;printf(" Thank You!! Wish You Have A Happy Day");for(;!kbhit();); break; case 5: gamespe
4、ed=s5;printf(" Thank You!! Wish You Have A Happy Day");for(;!kbhit();); break; case 6: gamespeed=s6;printf(" Thank You!! Wish You Have A Happy Day");for(;!kbhit();); break; default: printf(" Oh!! My God! Please Check The Number! Is it bewtten 1 and 6 ??");for(;!kbhit(););exit(0);
5、 } } int init() { auto int gdriver=DETECT,gmode,i,j; /* registerbgifont(); */ registerbgidriver(EGAVGA_driver); initgraph(&gdriver,&gmode,"E:\\tcpp\\bgi"); setbkcolor(9);setcolor(5);setlinestyle(0,0,3); for(i=0;i<=10;i++) { int c=i;if(c==9)c=3; for(j=0;j<=9;j++) { setfillstyle(1,c);c++;if(c=
6、=9)c=6; rectangle(j*60+15,20*i,60*j+75,20*i+20),flag[i][j]=1; floodfill(j*60+20,20*i+10,5); } }setfillstyle(1,15);floodfill(20,10,5);floodfill(380,210,5); setlinestyle(0,0,1); setfillstyle(1,BLUE); rectangle(50,460,110,480);floodfill(60,470,5); return 0; } int daba() { static int x=50; if(
7、!kbhit())return 0; else {int key; key=bioskey(0); switch(key) { case LEFT:setfillstyle(1,9);floodfill(x+10,470,5);setcolor(9);rectangle(x,460,x+60,480); setcolor(5);setfillstyle(1,BLUE); if(x<=9){rectangle(0,460,60,480);floodfill(40,470,5);x=0;}else{rectangle(x-10,460,x+50,480 );floodfill(x+20
8、,470,5);x-=10;}return 1; case RIGHT:setfillstyle(1,9);floodfill(x+10,470,5);setcolor(9);rectangle(x,460,x+60,480); setcolor(5);setfillstyle(1,BLUE); if(x>=579){rectangle(579,460,639,480);floodfill(600,470,5);x=579;}else{rectangle(x+10,46 0,x+70,480);floodfill(x+30,470,5);x+=10; }return 1; case ES
9、C: return 2; default: return 0; } } return 0; } int Juge(int &direction,int x,int y) {int i,j,k; if(y>=240) return 0; switch(direction) { case 1: for(k=0;k<=10&&fabs(y-41-20*k)>=3;k++);i=k;if(i==11)return 0;for(k=0;k<=9&&!(x>=60*k-5&&x<=60*k+95);k++);j=k; if(flag[i][j]==1){setlinestyle(0,
10、0,3);setcolor(9);setfillstyle(1,9);floodfill(60*j+20,20*i+10,5);recta ngle(60*j+15,20*i,60*j+75,20*i+20);score+=1;setcolor(5); if(j>=1&&flag[i][j-1]!=0)rectangle(60*j+15-60,20*i,60*j+15,20*i+20);if(j==0&&flag[i][j+1]!=0) rectangle(15,20*i,75,20*i+20);if(j==9&&flag[i][j-1]!=0)rectangle(60*9+15,20*i,
11、60*9+75,20*i+2 0);if(j<=8&&flag[i][j+1]!=0)rectangle(60*j+75,20*i,60*j+75+60,20*i+20);if(i>=1&&flag[i-1][j]! =0)rectangle(60*j+15,20*i-20,60*j+75,20*i);flag[i][j]=0;direction=-2;return 1;} else if(flag[i][j-1]==0)return 0;else if(x>=60*j+15+8)return 0;else{direction=-2;return 1;} case 2: for(k=0;k
12、<=10&&fabs(y-41-20*k)>=3;k++);i=k;if(i==11)return 0;for(k=0;k<=9&&!(x>=60*k-5&&x<=60*k+95);k++);j=k; if(flag[i][j]==1){setlinestyle(0,0,3);score+=1;setcolor(9);setfillstyle(1,9);floodfill(60*j+20,20*i+1 0,5);rectangle(60*j+15,20*i,60*j+75,20*i+20);flag[i][j]=0;direction=-1;setcolor(5);if(j==0&&fla g
13、[i][j+1]!=0)rectangle(15,20*i,75,20*i+20);if(j==9&&flag[i][j-1]!=0)rectangle(60*9+15,20*i,60* 9+75,20*i+20);if(j>=1&&flag[i][j-1]!=0)rectangle(60*j+15-60,20*i,60*j+15,20*i+20);if(j<=8& &flag[i][j+1]!=0)rectangle(60*j+75,20*i,60*j+75+60,20*i+20);if(i>=1&&flag[i-1][j]!=0)rectangl e(60*j+15,20*i-20,60*
14、j+75,20*i); return 1;} else if(flag[i][j+1]==0)return 0;else if(x<=60*j+15-8)return 0;else{direction=-1;return 1;} case -1:for(k=2;k<=10&&fabs(y+20-20*k)>=2;k++);i=k;if(i==11)return 0;for(k=0;k<=9&&!(x>=60*k-5&&x<=60*k+95);k++);j=k; if(flag[i][j]==1){setlinestyle(0,0,3);setcolor(9);setfillstyle(1,9
15、);floodfill(60*j+20,20*i+10,5);recta ngle(60*j+15,20*i,60*j+75,20*i+20);score+=1;setcolor(5); if(j>=1&&flag[i][j-1]!=0)rectangle(60*j+15-60,20*i,60*j+15,20*i+20);if(j==0&&flag[i][j+1]!=0) rectangle(15,20*i,75,20*i+20);if(j==9&&flag[i][j-1]!=0)rectangle(60*9+15,20*i,60*9+75,20*i+2 0);if(j<=8&&flag[i]
16、[j+1]!=0)rectangle(60*j+75,20*i,60*j+75+60,20*i+20);if(i<=8&&flag[i+1][j] !=0)rectangle(60*j+15,20*i-20,60*j+75,20*i); flag[i][j]=0;direction=2;return 1; } else if(flag[i][j+1]==0&&flag[i][j-1]==0)return 0;else if(x<=60*i+15-68)return 0;else {direction=2;return 1;} case -2:for(k=2;k<=10&&fabs(y+20-
17、20*k)>=2;k++);i=k;if(i==11)return 0;for(k=0;k<=9&&!(x>=60*k-5&&x<=60*k+95);k++);j=k; if(flag[i][j]==1){setlinestyle(0,0,3);setcolor(9);setfillstyle(1,9);floodfill(60*j+20,20*i+10,5);recta ngle(60*j+15,20*i,60*j+75,20*i+20);score+=1;setcolor(5); if(j>=1&&flag[i][j-1]!=0)rectangle(60*j+15-60,20*i,60*j
18、+15,20*i+20);if(j==0&&flag[i][j+1]!=0) rectangle(15,20*i,75,20*i+20);if(j==9&&flag[i][j-1]!=0)rectangle(60*9+15,20*i,60*9+75,20*i+2 0);if(j<=8&&flag[i][j+1]!=0)rectangle(60*j+75,20*i,60*j+75+60,20*i+20);if(i<=8&&flag[i+1][j] !=0)rectangle(60*j+15,20*i-20,60*j+75,20*i); flag[i][j]=0;direction=2;retur
19、n 1; } else if(flag[i][j+1]==0&&flag[i][j-1]==0)return 0;else if(x<=60*i+15-68)return 0;else {direction=2;return 1;} } return 0; } int play() {int key,x=50,x0=80,y0=436,direction;char *s; void*buf1;randomize();direction=rand()%1+1; setcolor(5);circle(x0,y0,20);setfillstyle(1,8);floodfill(x0,y0,
20、5); buf1=malloc(imagesize(59,415,102,458));getimage(59,415,102,458,buf1); while(1) { while(!kbhit()) {swi:switch(direction) { case 1:for(;y0>=21&&x0>=21;x0--,y0--) {if(kbhit())goto loop;delay(gamespeed); if(Juge(direction,x0,y0)!=0)goto swi; putimage(x0-22,y0-22,buf1,0); }x0++,y0++;if(x0==21)d
21、irection=2;else direction=-2;break; case 2:for(;x0<=617&&y0>=21;x0++,y0--) {if(kbhit())goto loop;delay(gamespeed); if(Juge(direction,x0,y0)!=0)goto swi; putimage(x0-22,y0-22,buf1,0); }x0--,y0++;if(x0==617)direction=1;else direction=-1; break; case -1:for(;x0<=617&&y0<=436;x0++,y0++) {if(kbhit()
22、)goto loop;delay(gamespeed); if(Juge(direction,x0,y0)!=0)goto swi; putimage(x0-22,y0-22,buf1,0); }x0--,y0--;if(y0==436){if(x0+20>=x&&x0-20<=x+60)direction=2;else{ for(;y0<=500;y0 ++,x0++){delay(gamespeed); putimage(x0-22,y0-22,buf1,0);} return 0;} }else direction=-2; break; case -2:for(;x0>=21&&
23、y0<=436;x0--,y0++) {if(kbhit())goto loop;delay(gamespeed); if(Juge(direction,x0,y0)!=0)goto swi; putimage(x0-22,y0-22,buf1,0); }x0++,y0--;if(y0==436){if(x0+20>=x&&x0-20<=x+60) direction=1;else{ for(;y0<=500;y0++,x0--){delay(gamespeed); putimage(x0-22,y0-22,buf1,0);} return 0;} }else direction=-1;
24、 break; } }loop: key=bioskey(0); switch(key) { case LEFT:setfillstyle(1,9);floodfill(x+10,470,5);setcolor(9);rectangle(x,460,x+60,480);bar(x,460,x+60 ,480); setcolor(5);setfillstyle(1,BLUE); if(x<=9){sprintf(s,"%d",score);outtextxy(10,470,s); rectangle(0,460,60,480);floodfill(40,470,5);x=0;}els
25、e{sprintf(s,"%d",score);outtextxy(x,470,s); rectangle(x-10,460,x+50,480);floodfill(x+20,470,5);x-=10;}break; case RIGHT:setfillstyle(1,9);floodfill(x+10,470,5);setcolor(9);rectangle(x,460,x+60,480);bar(x,460,x+ 60,480); setcolor(5);setfillstyle(1,BLUE); if(x>=579){sprintf(s,"%d",score);outtextxy(5
26、89,470,s); rectangle(579,460,639,480);floodfill(600,470,5);x=579;}else{sprintf(s,"%d",score);outtextxy(x+2 0,470,s);rectangle(x+10,460,x+70,480);floodfill(x+30,470,5);x+=10; }break; case ESC: break; default: break; }if(key==ESC)break; }return 0; int main() { chose(); init(); play(); getch(); closegraph(); return 0; }
- 溫馨提示:
1: 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 110中國人民警察節(jié)(筑牢忠誠警魂感受別樣警彩)
- 2025正字當(dāng)頭廉字入心爭當(dāng)公安隊(duì)伍鐵軍
- XX國企干部警示教育片觀后感筑牢信仰之基堅(jiān)守廉潔底線
- 2025做擔(dān)當(dāng)時(shí)代大任的中國青年P(guān)PT青年思想教育微黨課
- 2025新年工作部署會(huì)圍繞六個(gè)干字提要求
- XX地區(qū)中小學(xué)期末考試經(jīng)驗(yàn)總結(jié)(認(rèn)真復(fù)習(xí)輕松應(yīng)考)
- 支部書記上黨課筑牢清廉信念為高質(zhì)量發(fā)展?fàn)I造風(fēng)清氣正的環(huán)境
- 冬季消防安全知識(shí)培訓(xùn)冬季用電防火安全
- 2025加強(qiáng)政治引領(lǐng)(政治引領(lǐng)是現(xiàn)代政黨的重要功能)
- 主播直播培訓(xùn)直播技巧與方法
- 2025六廉六進(jìn)持續(xù)涵養(yǎng)良好政治生態(tài)
- 員工職業(yè)生涯規(guī)劃方案制定個(gè)人職業(yè)生涯規(guī)劃
- 2024年XX地區(qū)黨建引領(lǐng)鄉(xiāng)村振興工作總結(jié)
- XX中小學(xué)期末考試經(jīng)驗(yàn)總結(jié)(認(rèn)真復(fù)習(xí)輕松應(yīng)考)
- 幼兒園期末家長會(huì)長長的路慢慢地走