當前位置:編程學習大全網 - 源碼下載 - Tc遊戲源代碼

Tc遊戲源代碼

速度和連接板長度不能改變。

所以更難玩了。

#包含“graphics.h”

#包含“stdio.h”

#include "conio.h" /*必需的頭文件*/

int on/*用切換函數聲明壹個全局變量*/

靜態int分數;/*聲明靜態計分器變量*/

/*定義啟動接口函數*/

int open()

{

setviewport(100,100,500,380,1);/*設置圖形窗口區域*/

set color(4);/*設置繪圖顏色*/

矩形(0,0,399,279);/*用矩形填充設定的圖形窗口區域*/

setfillstyle(SOLID_FILL,7);/*設置填充方法*/

洪水填充(50,50,4);/*設置填充範圍*/

set color(8);

settextstyle(0,0,9);/*文本字體設置*/

outtextxy(90,80,“球”);/*輸出文本內容*/

settextstyle(0,0,1);

outtextxy(110,180,“版本1.0”);

outtextxy(110,190,“滴滴涕制造”);

set color(128);

settextstyle(0,0,1);

outtextxy(120,240,"按任意鍵繼續……");

}

/*定義退出接口函數*/

int quitwindow()

{

char s[100];/*聲明用於存儲字符串的數組*/

setviewport(100,150,540,420,1);

setcolor(黃色);

矩形(0,0,439,279);

setfillstyle(SOLID_FILL,7);

漫填(50,50,14);

set color(12);

settextstyle(0,0,8);

outtextxy(120,80," End ");

settextstyle(0,0,2);

outtextxy(120,200,“退出?y/N”);

sprintf(s,“妳的分數是:%d”,分數);/*打印格式計分器的值*/

outtextxy(120,180,s);

on = 1;/*初始化開關變量*/

}

/*主函數*/

主()

{

int gdriver,gmode

gdriver = DETECT/*設置圖形適配器*/

gmode = 0;/*設置圖形模式*/

registerbgidriver(EGA VGA _ driver);/*註冊BGI驅動程序後,它可以在沒有支持的情況下運行。BGI文件*/

init graph(& amp;g driver & amp;gmode,“”;

setbkcolor(14);

open();/*調用啟動接口函數*/

getch();/*暫停*/

而(1) /*這個大循環控制著遊戲的重復進行*/

{

int驅動,mode,l=320,t=400,r,a,b,dl=5,n,x=200,y=400,r1=10,dx=-2,dy =-2;/*初始化球的相關參數*/

int left[100],top[100],right[100],bottom[100],I,j,k,off=1,m,num[100][100];/*方磚陣列的相關參數*/

靜態int pp

靜態int短語;/*壹系列充當開關的變量*/

int OOP = 15;

PP = 1;

得分= 0;

驅動=檢測;

mode = VGA

registerbgidriver(EGA VGA _ driver);

init graph(& amp;司機& amp模式,“”;

setbkcolor(10);

clear device();/*在圖形狀態下清除屏幕*/

clear viewport();/*清除當前圖形窗口的內容*/

b = t+6;

r = l+60;

set color(1);

矩形(0,0,639,479);

set color(4);

矩形(l,t,r,b);

setfillstyle(SOLID_FILL,1);

洪水填充(l+2,t+2,4);

for(i=0,k = 0;我& lt=6;I++) /*此循環繪制壹個方形磚塊數組*/

{

top[I]= k;

bottom[I]= top[I]+20;

k = k+21;

OOP-;

for(j=0,m = 0;j & lt=7;j++)

{

left[j]= m;

右[j]=左[j]+80;

m = m+81;

set color(4);

矩形(左[j],上[i],右[j],下[I]);

setfillstyle(SOLID_FILL,j+OOP);

floodfill(left[j]+1,top[i]+1,4);

num[I][j]= pp++;

}

}

While(1) /*該循環控制整個動畫*/

{

而(!kbhit())

{

x = x+dx;/*球運動的中心可變控制*/

y = y+dy;

if(x+r 1 & gt;r | | x+r 1 & lt;r)

{ phrase = 0;}

if((x-r 1 & lt;= r | | x+r 1 & lt;= r)& amp;& ampx+r 1 & gt;=l)

{

if(y & lt;t)

phrase = 1;

if(y+r 1 & gt;= t & amp& amp短語==1)

{ dy =-dy;y = t-1-r 1;}

}

if(off==0)

繼續;

for(I = 0;我& lt=6;I++) /*此循環用於判斷和控制方塊磚數組的沖擊和擦除*/

for(j = 0;j & lt=7;j++)

{

if((x+r 1 & lt;= right[j]& amp;& ampx+r 1 & gt;= left[j])| |(x-r 1 & lt;= right[j]& amp;& ampx-r 1 & gt;=left[j]))

{

if((y-r 1 & gt;top[I]& amp;& ampy-r 1 & lt;= bottom[I])| |(y+r 1 & gt;= top[I]& amp;& ampy+r 1 & lt;=bottom[i])

{

if(num[i][j]==0)

{繼續;}

set color(10);

矩形(左[j],上[i],右[j],下[I]);

setfillstyle(SOLID_FILL,10);

floodfill(左[j]+1,上[i]+1,10);

dy =-dy;

num[I][j]= 0;

得分=分數+10;

printf("%d\b\b\b ",分數);

}

}

if((y+r 1 & gt;= top[I]& amp;& ampy+r 1 & lt;= bottom[I])| |(y-r 1 & gt;= top[I]& amp;& ampy-r 1 & lt;=bottom[i])

{

if((x+r 1 & gt;= left[j]& amp;& ampx+r 1 & lt;right[j])| |(x-r 1 & lt;= right[j]& amp;& ampx-r 1 & gt;左[j]))

{

if(num[i][j]==0)

{繼續;}

set color(10);

矩形(左[j],上[i],右[j],下[I]);

setfillstyle(SOLID_FILL,10);

floodfill(左[j]+1,上[i]+1,10);

dx =-dx;

num[I][j]= 0;

得分=分數+10;

printf("%d\b\b\b ",分數);

}

}

}

if(x+r 1 & gt;639) /*控制球的彈出範圍*/

{ dx =-dx;x = 638-r 1;}

if(x & lt;=r1)

{ dx =-dx;x = r 1+1;}

if(y+r 1 & gt;=479)

{ off = 0;quit window();打破;}

if(y & lt;=r1)

{ dy =-dy;y = r 1+1;}

如果(分數==560)

{ off = 0;quit window();打破;}

set color(6);

circle(x,y,r 1);

setfillstyle(SOLID_FILL,14);

floodfill(x,y,6);

延時(1000);

set color(10);

circle(x,y,r 1);

setfillstyle(SOLID_FILL,10);

floodfill(x,y,10);

}

a = getch();

set color(10);

矩形(l,t,r,b);

setfillstyle(SOLID_FILL,10);

漫填(l+2,t+2,10);

if(a = = 77 & amp;& ampl & lt=565) /*鍵盤控制設置*/

{ dl = 20l = l+dl;}

if(a = = 75 & amp;& ampl & gt=15)

{ dl =-20;l = l+dl;}

if(a = = ' y ' & amp;& ampon==1)

打破;

if(a = = ' n ' & amp;& ampon==1)

打破;

如果(a==27)

{ quit window();關= 0;}

r = l+60;

set color(4);

矩形(l,t,r,b);

setfillstyle(SOLID_FILL,1);

漫填(l+5,t+5,4);

延時(100);

}

if(a = = ' y ' & amp;& ampOn==1) /*是否要退出遊戲*/

{ break}

if(a = = ' n ' & amp;& ampon==1)

{繼續;}

}

closegraph();

}

妳不是要求在TC運行嗎

C++和c不壹樣。

如果妳想在C++中

妳必須先寫函數的聲明。

不是c調的。

已經修改過了。試試看。

我可以在這裏做。

那是壹閃而過的圖形界面問題。

驅動程序安裝不正確。

  • 上一篇:大數據分析處理 應多元化
  • 下一篇:我想把這個指標用通達信選股器選出來,條件是出現“看底”的時候,求高手幫忙!
  • copyright 2024編程學習大全網