導航:首頁 > 源碼編譯 > 編譯游戲大全

編譯游戲大全

發布時間:2022-05-06 10:24:38

❶ C語言可以寫哪些小游戲

C語言可以編手機游戲. 你叫他去死 不過我這有 貪吃蛇的代碼,你倒可以看看 (用TC 編譯一定過)

#include
#include
#include
#include
#include
#define Enter 7181
#define ESC 283
#define UP 18432
#define DOWN 20480
#define LEFT 19200
#define RIGHT 19712
#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif
void interrupt (*oldhandler)(__CPPARGS);
void interrupt newhandler(__CPPARGS);
void SetTimer(void interrupt (*IntProc)(__CPPARGS));
void KillTimer(void);
void Initgra(void);
void TheFirstBlock(void);
void DrawMap(void);
void Initsnake(void);
void Initfood(void);
void Snake_Headmv(void);
void Flag(int,int,int,int);
void GameOver(void);
void Snake_Bodymv(void);
void Snake_Bodyadd(void);
void PrntScore(void);
void Timer(void);
void Win(void);
void TheSecondBlock(void);
void Food(void);
void Dsnkorfd(int,int,int);
void Delay(int);
struct Snake
{int x;int y;int color;}Snk[12];
struct Food
{int x;int y;int color;}Fd;
int flag1=1,flag2=0,flag3=0,flag4=0,flag5=0,flag6=0,
checkx,checky,num,key=0,Times,Score,Hscore,Snkspeed,TimerCounter,TureorFalse;
char Sco[2],Time[6];
void main()
{ Initgra();
SetTimer(newhandler);
TheFirstBlock();
while(1)
{DrawMap();
Snake_Headmv();
GameOver();
Snake_Bodymv();
Snake_Bodyadd();
PrntScore();
Timer();
Win();
if(key==ESC)
break;
if(key==Enter)
{cleardevice();
TheFirstBlock();
}
TheSecondBlock();
Food();
Delay(Snkspeed);
}
closegraph();
KillTimer();
}
void interrupt newhandler(__CPPARGS)
{
TimerCounter++;
oldhandler();
}
void SetTimer(void interrupt (*IntProc)(__CPPARGS))
{
oldhandler=getvect(0x1c);
disable();
setvect(0x1c,IntProc);
enable();
}

void KillTimer()
{
disable();
setvect(0x1c,oldhandler);
enable();
}
void Initgra()
{int gd=DETECT,gm;
initgraph(&gd,&gm,"d:\\tc");
}
void TheFirstBlock()
{setcolor(11);
settextstyle(0,0,4);
outtextxy(100,220,"The First Block");
loop:key=bioskey(0);
if(key==Enter)
{cleardevice();
Initsnake();
Initfood();
Score=0;
Hscore=1;
Snkspeed=10;
num=2;
Times=0;
key=0;
TureorFalse=1;
TimerCounter=0;
Time[0]='0';Time[1]='0';Time[2]=':';Time[3]='1';Time[4]='0';Time[5]='\0';
}
else if(key==ESC) cleardevice();
else goto loop;
}
void DrawMap()
{line(10,10,470,10);
line(470,10,470,470);
line(470,470,10,470);
line(10,470,10,10);
line(480,20,620,20);
line(620,20,620,460);
line(620,460,480,460);
line(480,460,480,20);
}
void Initsnake()
{randomize();
num=2;
Snk[0].x=random(440);
Snk[0].x=Snk[0].x-Snk[0].x%20+50;
Snk[0].y=random(440);
Snk[0].y=Snk[0].y-Snk[0].y%20+50;
Snk[0].color=4;
Snk[1].x=Snk[0].x;
Snk[1].y=Snk[0].y+20;
Snk[1].color=4;
}
void Initfood()
{randomize();
Fd.x=random(440);
Fd.x=Fd.x-Fd.x%20+30;
Fd.y=random(440);
Fd.y=Fd.y-Fd.y%20+30;
Fd.color=random(14)+1;
}
void Snake_Headmv()
{if(bioskey(1))
{key=bioskey(0);
switch(key)
{case UP:Flag(1,0,0,0);break;
case DOWN:Flag(0,1,0,0);break;
case LEFT:Flag(0,0,1,0);break;
case RIGHT:Flag(0,0,0,1);break;

default:break;
}
}
if(flag1)
{checkx=Snk[0].x;
checky=Snk[0].y;
Dsnkorfd(Snk[0].x,Snk[0].y,0);
Snk[0].y-=20;
Dsnkorfd(Snk[0].x,Snk[0].y,Snk[0].color);
}
if(flag2)
{checkx=Snk[0].x;
checky=Snk[0].y;
Dsnkorfd(Snk[0].x,Snk[0].y,0);
Snk[0].y+=20;
Dsnkorfd(Snk[0].x,Snk[0].y,Snk[0].color);
}
if(flag3)
{checkx=Snk[0].x;
checky=Snk[0].y;
Dsnkorfd(Snk[0].x,Snk[0].y,0);
Snk[0].x-=20;
Dsnkorfd(Snk[0].x,Snk[0].y,Snk[0].color);
}
if(flag4)
{checkx=Snk[0].x;
checky=Snk[0].y;
Dsnkorfd(Snk[0].x,Snk[0].y,0);
Snk[0].x+=20;
Dsnkorfd(Snk[0].x,Snk[0].y,Snk[0].color);
}
}
void Flag(int a,int b,int c,int d)
{flag1=a;flag2=b;flag3=c;flag4=d;}
void GameOver()
{int i;
if(Snk[0].x460||Snk[0].y460)
{cleardevice();
setcolor(11);
settextstyle(0,0,4);
outtextxy(160,220,"Game Over");
loop1:key=bioskey(0);
if(key==Enter)
{cleardevice();
TheFirstBlock();
}
else
if(key==ESC)
cleardevice();
else
goto loop1;
}
for(i=3;i<num;i++)
{if(Snk[0].x==Snk[i].x&&Snk[0].y==Snk[i].y)
{cleardevice();
setcolor(11);
settextstyle(0,0,4);
outtextxy(160,220,"Game Over");
loop2:key=bioskey(0);
if(key==Enter)
{cleardevice();
TheFirstBlock();
}
else
if(key==ESC)
cleardevice();
else goto loop2;
}
}
}
void Snake_Bodymv()
{int i,s,t;
for(i=1;i<num;i++)
{Dsnkorfd(checkx,checky,Snk[i].color);
Dsnkorfd(Snk[i].x,Snk[i].y,0);
s=Snk[i].x;
t=Snk[i].y;
Snk[i].x=checkx;
Snk[i].y=checky;
checkx=s;
checky=t;
}
}
void Food()
{if(flag5)
{randomize();
Fd.x=random(440);
Fd.x=Fd.x-Fd.x%20+30;
Fd.y=random(440);
Fd.y=Fd.y-Fd.y%20+30;
Fd.color=random(14)+1;
flag5=0;
}
Dsnkorfd(Fd.x,Fd.y,Fd.color);
}
void Snake_Bodyadd()
{if(Snk[0].x==Fd.x&&Snk[0].y==Fd.y)
{if(Snk[num-1].x>Snk[num-2].x)
{num++;
Snk[num-1].x=Snk[num-2].x+20;
Snk[num-1].y=Snk[num-2].y;
Snk[num-1].color=Fd.color;
}
else
if(Snk[num-1].x<Snk[num-2].x)
{num++;
Snk[num-1].x=Snk[num-2].x-20;
Snk[num-1].y=Snk[num-2].y;
Snk[num-1].color=Fd.color;
}
else
if(Snk[num-1].y>Snk[num-2].y)
{num++;
Snk[num-1].x=Snk[num-2].x;
Snk[num-1].y=Snk[num-2].y+20;
Snk[num-1].color=Fd.color;
}
else
if(Snk[num-1].y<Snk[num-2].y)
{num++;
Snk[num-1].x=Snk[num-2].x;
Snk[num-1].y=Snk[num-2].y-20;
Snk[num-1].color=Fd.color;
}
flag5=1;
Score++;
}
}
void PrntScore()
{if(Hscore!=Score)
{setcolor(11);
settextstyle(0,0,3);
outtextxy(490,100,"SCORE");
setcolor(2);
setfillstyle(1,0);
rectangle(520,140,580,180);
floodfill(530,145,2);
Sco[0]=(char)(Score+48);
Sco[1]='\0';
Hscore=Score;
setcolor(4);
settextstyle(0,0,3);
outtextxy(540,150,Sco);
}
}
void Timer()
{if(TimerCounter>18)
{Time[4]=(char)(Time[4]-1);
if(Time[4]<'0')
{Time[4]='9';
Time[3]=(char)(Time[3]-1);
}
if(Time[3]<'0')
{Time[3]='5';
Time[1]=(char)(Time[1]-1);
}
if(TureorFalse)
{setcolor(11);
settextstyle(0,0,3);
outtextxy(490,240,"TIMER");
setcolor(2);
setfillstyle(1,0);
rectangle(490,280,610,320);
floodfill(530,300,2);
setcolor(11);
settextstyle(0,0,3);
outtextxy(495,290,Time);
TureorFalse=0;
}
if(Time[1]=='0'&&Time[3]=='0'&&Time[4]=='0')
{setcolor(11);
settextstyle(0,0,4);
outtextxy(160,220,"Game Over");
loop:key=bioskey(0);
if(key==Enter)
{cleardevice();
TheFirstBlock();
}
else if(key==ESC) cleardevice();
else goto loop;
}
TimerCounter=0;
TureorFalse=1;
}
}
void Win()
{if(Score==3)
Times++;
if(Times==2)
{cleardevice();
setcolor(11);
settextstyle(0,0,4);
outtextxy(160,220,"You Win");
loop:key=bioskey(0);
if(key==Enter)
{cleardevice();
TheFirstBlock();
key=0;
}
else if(key==ESC) cleardevice();
else goto loop;
}
}
void TheSecondBlock()
{if(Score==3)
{cleardevice();
setcolor(11);
settextstyle(0,0,4);
outtextxy(100,220,"The Second Block");
loop:key=bioskey(0);
if(key==Enter)
{cleardevice();
Initsnake();
Initfood();
Score=0;
Hscore=1;
Snkspeed=8;
num=2;
key=0;
}
else if(key==ESC) cleardevice();
else goto loop;
}
}
void Dsnkorfd(int x,int y,int color)
{setcolor(color);
setfillstyle(1,color);
circle(x,y,10);
floodfill(x,y,color);
}
void Delay(int times)
{int i;
for(i=1;i<=times;i++)
delay(15000);
}

❷ 我在找一些編譯游戲用的軟體

你可以下個綜合的 易語言http://www.dywt.com.cn/edown/e/E51/e51_chs_all.exe

❸ 求各種C語言編程小游戲,越多越好,多了會有加分

C語言數字記憶小游戲,望採納

#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
#include<time.h>
#defineTURE1
#defineFALSE0

voidmain()

{
charanother_name='Y';
charanother_game='Y';

intcorrect='TRUE';
intcounter=0;
intsequence_length=0;
inti=0;
longintseed=0;
intnumber=0;
longintnow=0;
longtime_taken=0;
intclock_per_sec;

printf(" ---------------------------------記憶小游戲-------------------------------------------- ");
printf("請牢記屏幕上出現的沒一個數字,並在規定時間內輸入您記下的數字。 ");
printf("回車開始游戲。 ");

scanf("%c",&another_game);

do
{
correct='TRUE';
counter=0;
sequence_length=2;
time_taken=clock();

while(correct)
{
sequence_length+=(counter++%3==0);
seed=time(NULL);
now=clock();
srand((int)seed);
for(i=0;i<=sequence_length;i++)
printf("%d",rand()%10);
for(;clock()-now<clock_per_sec;);
printf(" ");
for(i=0;i<=sequence_length;i++)
printf("");
if(counter==1)
printf(" 輸入您記住的數字,以空格隔開。 ");
else
printf(" ");
srand((int)seed);
for(i=0;i<=sequence_length;i++)
{
scanf("%d",&number);
if(number!=rand()%10)
{
correct=FALSE;
break;

}

}
printf("%s ",correct?"正確!":"錯誤!");

}
time_taken=(clock()-time_taken)/clock_per_sec;
printf(" 您的成績是:%d",--counter*100/time_taken);
fflush(stdin);
printf(" 是否繼續游戲?(Y/N)? ");
scanf("%c",&another_game);

}
while(another_game=='y'||another_game=='Y');
}

❹ 急求C語言編譯的小游戲.EXE五指棋的程序,附帶源代碼和注釋,最好注釋詳細一些

#include <graphics.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#define backcolor CYAN
#define defaultcolor BLACK
#define linecolor MAGENTA
#define player1_color RED
#define player2_color WHITE
#define error_color RED
#define winner_color RED

const int left=40;
const int top=390;
const int d=30;
const int line_num=9;
const int turn=0;
const int r=d/3;
const int j=10;
int x,y,k=1,step=(line_num+1)*(line_num+1);
union REGS regs1,regs2;
class player1;
class player2;
class qipan{
public:
qipan();
~qipan(){};
void init_qipan();
friend void fall(player1 &num1,player2 &num2,qipan &num);
friend void input(player1 &num1,player2 &num2,qipan &num);

private:
int point[line_num+1][line_num+1];

};
class player1{
public:
player1();
~player1(){};
friend void fall(player1 &num1,player2 &num2,qipan &num);
friend void input(player1 &num1,player2 &num2);
friend int judge_winner(player1 &num1,player2 &num2);
private:
int point1[line_num+1][line_num+1];
};
class player2{
public:
player2();
~player2(){};
friend void fall(player1 &num1,player2 &num2,qipan &num);
friend void input(player1 &num1,player2 &num2,qipan &num);
friend int judge_winner(player1 &num1,player2 &num2);
private:
int point2[line_num+1][line_num+1];
};
void input(player1 &num1,player2 &num2);
void fall(player1 &num1,player2 &num2,qipan &num);
int judge_winner(qipan &num,player1 &num1,player2 &num2);
void inputerror();
void display_winner(int);

void main()
{
int driver=DETECT,mode;
initgraph(&driver,&mode,"e:\tc30\bgi");

qipan num;
player1 num1;
player2 num2;
while(step--)
{
input(num1,num2,num);
fall(num1,num2,num);
if(judge_winner(num1,num2))
{
display_winner(k);
}
}

// getchar();
}
qipan::qipan(void)
{ int j,i;
char ch[2]="0";
setbkcolor(backcolor);
setcolor(linecolor);
for(i=0;i<=line_num;i++)
{
line(left,top-i*d,left+line_num*d,top-i*d);
}
for(i=0;i<=line_num;i++)
{
line(left+i*d,top,left+i*d,top-line_num*d);
}
for(i=0;i<=line_num;i++)
{ if(*ch=='9'+1) *ch='a';
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
outtextxy(left+i*d-2,top+r+3,ch);
(*ch)=(*ch)+1;
}
*ch='0';
for(i=0;i<=line_num;i++)
{if(*ch=='9'+1) *ch='a';
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
outtextxy(left-r-10,top-d*i-3,ch);
(*ch)=(*ch)+1;
}

setcolor(defaultcolor);

for(i=0;i<=line_num;i++)
{
for(j=0;j<=line_num;j++)
point[i][j]=0;
}
}

void fall(player1 &num1,player2 &num2,qipan &num)
{
int flag=k%2;
if(flag)
{ setcolor(player2_color);
num2.point2[x][y]=1;
num.point[x][y]=2;
circle(left+d*x,top-d*y,r);
setfillstyle(1,player2_color);
floodfill(left+d*x,top-d*y,player2_color);
}
else
{ num1.point1[x][y]=1;
num.point[x][y]=1;
setcolor(player1_color);
circle(left+d*x,top-d*y,r);
setfillstyle(1,player1_color);
floodfill(left+d*x,top-d*y,player1_color);
}

setcolor(defaultcolor);
}

void input(player1 &num1,player2 &num2,qipan &num)
{ char xx,yy;

k++;
while(1)
{
regs1.h.ah=0;
xx=int86(22,?s1,?s1)-'0';
if(xx==('q'-'0')||xx==('Q'-'0'))
{ step=0;
return;
}
regs1.h.ah=0;
yy=int86(22,?s1,?s1)-'0';

if(yy==('q'-'0')||yy==('Q'-'0'))
{
step=0;
return ;
}
if(xx<0||xx>line_num)
{ inputerror();
continue;
}
if(yy<0||yy>line_num)
{inputerror();
continue;
}

if(num.point[xx][yy]==0)
{
break;
}
else
{
inputerror();
continue;
}
}

x=(int)xx;
y=(int)yy;

setcolor(backcolor);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
outtextxy(left+d*line_num/3,top+d*2,"Input error");
setcolor(defaultcolor);
}

player1::player1()
{
int i,j;
for(i=0;i<=line_num;i++)
{
for(j=0;j<=line_num;j++)
point1[i][j]=0;
}
}

player2::player2()
{ int i,j;
for(i=0;i<=line_num;i++)
{
for(j=0;j<=line_num;j++)
point2[i][j]=0;
}
}
void inputerror(void)
{ setcolor(error_color);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
outtextxy(left+d*line_num/3,top+d*2,"Input error");
setcolor(defaultcolor);
}

int judge_winner(player1 &num1,player2 &num2)
{
int count=0,m=0,n=0,a=0,b=0,xx0,yy0;
int flag=k%2;
xx0=x; yy0=y;
if(!flag)
{ //left <-------> right
while(xx0>=1&&m<4) {xx0--;m++;}
while(n<9&&xx0<=line_num)
{
if(num1.point1[xx0][y]==1)
{
count++;
if(count==5) return 1;
}
else
{
count=0;
}
n++;
xx0++;
}
//up <------> down
count=0; xx0=x; m=0; n=0;
while(yy0>=1&&m<4){yy0--;m++;}
while(n<9&&yy0<=line_num)
{
if(num1.point1[x][yy0]==1)
{
count++;
if(count==5)
return 1;
}
else
{
count=0;
}
n++;
yy0++;
}
//left up ----- right down
xx0=x;
yy0=y;
m=0;
n=0;
count=0;
while(xx0>=1&&m<4){ xx0--; a++; m++;} m=0;
while(yy0<=line_num&&m<4){ yy0++; b++; m++;}
if(a<=b)
{
xx0=x-a; yy0=y+a;
}
else
{
xx0=x-b; yy0=y+b;
}
while(xx0<=line_num&&yy0>=0&&n<9)
{
if(num1.point1[xx0][yy0]==1)
{
count++;
if(count==5)
return 1;
}
else
{
count=0;
}
xx0++;
yy0--;
n++;
}
//right up <-----> left down
count=0;
a=0;
b=0;
n=0;
m=0;
xx0=x;
yy0=y;
while(xx0<line_num&&m<4){ xx0++; m++; a++;} m=0;
while(yy0<line_num&&m<4){ yy0--; m++; b++; }
if(a<=b)
{
xx0=x+a;
yy0=y+a;
}
else
{
xx0=x+b;
yy0=y+b;
}
while(xx0>=0&&yy0>=0&&n<9)
{
if(num1.point1[xx0][yy0]==1)
{
count++;
if(count==5)
return 1;
}
else
count=0;
xx0--;
yy0--;
n++;
}
//no winer
return 0;
}
else
{
//left <-------> right
while(xx0>=1&&m<4) {xx0--;m++;}
while(n<9&&xx0<=line_num)
{
if(num1.point1[xx0][y]==1)
{
count++;
if(count==5) return 1;
}
else
{
count=0;
}
n++;
xx0++;
}
//up <------> down
count=0; xx0=x; m=0; n=0;
while(yy0>=1&&m<4){yy0--;m++;}
while(n<9&&yy0<=line_num)
{
if(num2.point2[x][yy0]==1)
{
count++;
if(count==5)
return 1;
}
else
{
count=0;
}
n++;
yy0++;
}
//left up ----- right down
xx0=x;
yy0=y;
m=0;
n=0;
count=0;
while(xx0>=1&&m<4){ xx0--; a++; m++;} m=0;
while(yy0<=line_num&&m<4){ yy0++; b++; m++;}
if(a<=b)
{
xx0=x-a; yy0=y+a;
}
else
{
xx0=x-b; yy0=y+b;
}
while(xx0<=line_num&&yy0>=0&&n<9)
{
if(num2.point2[xx0][yy0]==1)
{
count++;
if(count==5)
return 1;
}
else
{
count=0;
}
xx0++;
yy0--;
n++;
}
//right up <-----> left down
count=0;
a=0;
b=0;
n=0;
m=0;
xx0=x;
yy0=y;
while(xx0<line_num&&m<4){ xx0++; m++; a++;} m=0;
while(yy0<line_num&&m<4){ yy0--; m++; b++; }
if(a<=b)
{
xx0=x+a;
yy0=y+a;
}
else
{
xx0=x+b;
yy0=y+b;
}
while(xx0>=0&&yy0>=0&&n<9)
{
if(num2.point2[xx0][yy0]==1)
{
count++;
if(count==5)
return 1;
}
else
count=0;
xx0--;
yy0--;
n++;
}
//no winer
return 0;

}
}

void display_winner(int k)
{
int flag=k%2;
if(!flag)
{ setcolor(winner_color);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(left+d*2,top+40,"Red is winner");
setcolor(defaultcolor);
step=0;
getchar();
}
else
{ setcolor(winner_color);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(left+2*d,top+40,"White is winner");
setcolor(defaultcolor);
step=0;

}
}

❺ 除了Codecombat 還有哪些編程游戲可以玩

比如:
1、人力資源機器(human resource machine)

《人力資源機器》這款游戲與大家以往所玩過的其他代碼游戲都有所不同,雖然在分類上他屬於一個益智策略類游戲,但是在玩法上他完全是以一個現實中真實存在的職業技能作為基礎而改編的。在游戲中玩家要作為一個公司的小職員,來完成上司交給你的一些任務,而完成任務的方法就是要編寫一個足以達成目標的程序,並且按照程序中的條件進行活動。本作所採用的編程方式其實是一種相當古老的方法,只是符合一般的計算機邏輯思維,想要用這款游戲來學習專業編程似乎沒什麼卵用,不過沒有編程基礎的人玩起來應該會感到不解和困惑,但是看自己所設定的程序可以按照預想的效果來完美運營的話,那股油然而生的成就感絕對會讓自己的心情HIGH到爆炸。

2、康丁游戲CodinGame
CodinGame是一個游戲平台,游戲每一個練習背後的邏輯,都與一個實際的游戲相連,讓你能夠獲得實時視覺反饋,你完成練習之後也能獲得實際的獎勵。

CoinGame支持23種不同的編程語言,其中的每一個游戲練習都可以選擇自己熟悉的語言。在CodinGame平台,每一個練習都是基於瀏覽器的,會提供一個網路集成開發環境,讓你不刷新網頁就可以實時編譯代碼,並實時看到游戲的變化。目前,CodinGame已經吸引到了23萬用戶注冊。

此前,公司已經從天使投資者募集了50萬美元的資金。它們的競爭對手中包括了同樣是創新型編程練習平台的CodeFights,以及類似Treehosue和Code School這類傳統的編程學習網站。
3、代碼戰 CodeFights
CodeFights是一家將練習編程的過程變為游戲過程的初創公司。目前,該公司已經完成240萬的種子資金,以發展實時社交遊戲——在游戲中,碼農們既可以選擇人機對戰模式,也可以選擇挑戰其它玩家。

CodeFights有JavaScript、Java、C++和Python編程挑戰游戲,用戶們需要完成找出Bug的挑戰任務,勝利者就可以獲得相應的徽章。
4、代碼打獵Code Hunt

代碼打獵(Code Hunt)是Microsoft旗下新出的一款教育游戲,對大家感興趣編碼編碼基於瀏覽器的游戲。它供任何對編程有興趣的人學習代碼。該游戲呈現的方式並不是選擇答案的學習題,而是提供了一個可編輯的類似編碼界面,並在右邊不斷跳出程序的運行結果,測試運行結果是否符合要求。

❻ 誰給個破解手機單機游戲反編譯軟體

百分百網站,全是破解版的手機游戲,什麼游戲都有

❼ 有哪些游戲是用C++語言寫的

一般游戲mod都不會採用C++吧,C++需要編譯的.腳本語言如LUA才是正確的選擇.
我知道的LUA mod游戲:飢荒,Factorio.

❽ 急求C語言編譯的小游戲(如掃雷),附帶源代碼和注釋。

掃雷游戲(c語言版)
已經編譯運行確認了:

#include <graphics.h>
#include <stdlib.h>
#include <dos.h>
#define LEFTPRESS 0xff01
#define LEFTCLICK 0xff10
#define LEFTDRAG 0xff19
#define MOUSEMOVE 0xff08
struct
{
int num;/*格子當前處於什麼狀態,1有雷,0已經顯示過數字或者空白格子*/
int roundnum;/*統計格子周圍有多少雷*/
int flag;/*右鍵按下顯示紅旗的標志,0沒有紅旗標志,1有紅旗標志*/
}Mine[10][10];
int gameAGAIN=0;/*是否重來的變數*/
int gamePLAY=0;/*是否是第一次玩游戲的標志*/
int mineNUM;/*統計處理過的格子數*/
char randmineNUM[3];/*顯示數字的字元串*/
int Keystate;
int MouseExist;
int MouseButton;
int MouseX;
int MouseY;
void Init(void);/*圖形驅動*/
void MouseOn(void);/*滑鼠游標顯示*/
void MouseOff(void);/*滑鼠游標隱藏*/
void MouseSetXY(int,int);/*設置當前位置*/
int LeftPress(void);/*左鍵按下*/
int RightPress(void);/*滑鼠右鍵按下*/
void MouseGetXY(void);/*得到當前位置*/
void Control(void);/*游戲開始,重新,關閉*/
void GameBegain(void);/*游戲開始畫面*/
void DrawSmile(void);/*畫笑臉*/
void DrawRedflag(int,int);/*顯示紅旗*/
void DrawEmpty(int,int,int,int);/*兩種空格子的顯示*/
void GameOver(void);/*游戲結束*/
void GameWin(void);/*顯示勝利*/
int MineStatistics(int,int);/*統計每個格子周圍的雷數*/
int ShowWhite(int,int);/*顯示無雷區的空白部分*/
void GamePlay(void);/*游戲過程*/
void Close(void);/*圖形關閉*/
void main(void)
{
Init();
Control();
Close();
}
void Init(void)/*圖形開始*/
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc");
}
void Close(void)/*圖形關閉*/
{
closegraph();
}
void MouseOn(void)/*滑鼠游標顯示*/
{
_AX=0x01;
geninterrupt(0x33);
}
void MouseOff(void)/*滑鼠游標隱藏*/
{
_AX=0x02;
geninterrupt(0x33);
}
void MouseSetXY(int x,int y)/*設置當前位置*/
{
_CX=x;
_DX=y;
_AX=0x04;
geninterrupt(0x33);
}
int LeftPress(void)/*滑鼠左鍵按下*/
{
_AX=0x03;
geninterrupt(0x33);
return(_BX&1);
}
int RightPress(void)/*滑鼠右鍵按下*/
{
_AX=0x03;
geninterrupt(0x33);
return(_BX&2);
}
void MouseGetXY(void)/*得到當前位置*/
{
_AX=0x03;
geninterrupt(0x33);
MouseX=_CX;
MouseY=_DX;
}
void Control(void)/*游戲開始,重新,關閉*/
{
int gameFLAG=1;/*游戲失敗後判斷是否重新開始的標志*/
while(1)
{
if(gameFLAG)/*游戲失敗後沒判斷出重新開始或者退出遊戲的話就繼續判斷*/
{
GameBegain(); /*游戲初始畫面*/
GamePlay();/*具體游戲*/
if(gameAGAIN==1)/*游戲中重新開始*/
{
gameAGAIN=0;
continue;
}
}
MouseOn();
gameFLAG=0;
if(LeftPress())/*判斷是否重新開始*/
{
MouseGetXY();
if(MouseX>280&&MouseX<300&&MouseY>65&&MouseY<85)
{
gameFLAG=1;
continue;
}
}
if(kbhit())/*判斷是否按鍵退出*/
break;
}
MouseOff();
}
void DrawSmile(void)/*畫笑臉*/
{
setfillstyle(SOLID_FILL,YELLOW);
fillellipse(290,75,10,10);
setcolor(YELLOW);
setfillstyle(SOLID_FILL,BLACK);/*眼睛*/
fillellipse(285,75,2,2);
fillellipse(295,75,2,2);
setcolor(BLACK);/*嘴巴*/
bar(287,80,293,81);
}
void DrawRedflag(int i,int j)/*顯示紅旗*/
{
setcolor(7);
setfillstyle(SOLID_FILL,RED);
bar(198+j*20,95+i*20,198+j*20+5,95+i*20+5);
setcolor(BLACK);
line(198+j*20,95+i*20,198+j*20,95+i*20+10);
}
void DrawEmpty(int i,int j,int mode,int color)/*兩種空格子的顯示*/
{
setcolor(color);
setfillstyle(SOLID_FILL,color);
if(mode==0)/*沒有單擊過的大格子*/
bar(200+j*20-8,100+i*20-8,200+j*20+8,100+i*20+8);
else
if(mode==1)/*單擊過後顯示空白的小格子*/
bar(200+j*20-7,100+i*20-7,200+j*20+7,100+i*20+7);
}
void GameBegain(void)/*游戲開始畫面*/
{
int i,j;
cleardevice();
if(gamePLAY!=1)
{
MouseSetXY(290,70); /*滑鼠一開始的位置,並作為它的初始坐標*/
MouseX=290;
MouseY=70;
}
gamePLAY=1;/*下次按重新開始的話滑鼠不重新初始化*/
mineNUM=0;
setfillstyle(SOLID_FILL,7);
bar(190,60,390,290);
for(i=0;i<10;i++)/*畫格子*/
for(j=0;j<10;j++)
DrawEmpty(i,j,0,8);
setcolor(7);
DrawSmile();/*畫臉*/
randomize();__page_break__
for(i=0;i<10;i++)/*100個格子隨機賦值有沒有地雷*/
for(j=0;j<10;j++)
{
Mine[i][j].num=random(8);/*如果隨機數的結果是1表示這個格子有地雷*/
if(Mine[i][j].num==1)
mineNUM++;/*現有雷數加1*/
else
Mine[i][j].num=2;
Mine[i][j].flag=0;/*表示沒紅旗標志*/
}
sprintf(randmineNUM,"%d",mineNUM); /*顯示這次總共有多少雷數*/
setcolor(1);
settextstyle(0,0,2);
outtextxy(210,70,randmineNUM);
mineNUM=100-mineNUM;/*變數取空白格數量*/
MouseOn();
}
void GameOver(void)/*游戲結束畫面*/
{
int i,j;
setcolor(0);
for(i=0;i<10;i++)
for(j=0;j<10;j++)
if(Mine[i][j].num==1)/*顯示所有的地雷*/
{
DrawEmpty(i,j,0,RED);
setfillstyle(SOLID_FILL,BLACK);
fillellipse(200+j*20,100+i*20,7,7);
}
}
void GameWin(void)/*顯示勝利*/
{
setcolor(11);
settextstyle(0,0,2);
outtextxy(230,30,"YOU WIN!");
}
int MineStatistics(int i,int j)/*統計每個格子周圍的雷數*/
{
int nNUM=0;
if(i==0&&j==0)/*左上角格子的統計*/
{
if(Mine[0][1].num==1)
nNUM++;
if(Mine[1][0].num==1)
nNUM++;
if(Mine[1][1].num==1)
nNUM++;
}
else
if(i==0&&j==9)/*右上角格子的統計*/
{
if(Mine[0][8].num==1)
nNUM++;
if(Mine[1][9].num==1)
nNUM++;
if(Mine[1][8].num==1)
nNUM++;
}
else
if(i==9&&j==0)/*左下角格子的統計*/
{
if(Mine[8][0].num==1)
nNUM++;
if(Mine[9][1].num==1)
nNUM++;
if(Mine[8][1].num==1)
nNUM++;
}
else
if(i==9&&j==9)/*右下角格子的統計*/
{
if(Mine[9][8].num==1)
nNUM++;
if(Mine[8][9].num==1)
nNUM++;
if(Mine[8][8].num==1)
nNUM++;
}
else if(j==0)/*左邊第一列格子的統計*/
{
if(Mine[i][j+1].num==1)
nNUM++;
if(Mine[i+1][j].num==1)
nNUM++;
if(Mine[i-1][j].num==1)
nNUM++;
if(Mine[i-1][j+1].num==1)
nNUM++;
if(Mine[i+1][j+1].num==1)
nNUM++;
}
else if(j==9)/*右邊第一列格子的統計*/
{
if(Mine[i][j-1].num==1)
nNUM++;
if(Mine[i+1][j].num==1)
nNUM++;
if(Mine[i-1][j].num==1)
nNUM++;
if(Mine[i-1][j-1].num==1)
nNUM++;
if(Mine[i+1][j-1].num==1)
nNUM++;
}
else if(i==0)/*第一行格子的統計*/
{
if(Mine[i+1][j].num==1)
nNUM++;
if(Mine[i][j-1].num==1)
nNUM++;
if(Mine[i][j+1].num==1)
nNUM++;
if(Mine[i+1][j-1].num==1)
nNUM++;
if(Mine[i+1][j+1].num==1)
nNUM++;
}
else if(i==9)/*最後一行格子的統計*/
{
if(Mine[i-1][j].num==1)
nNUM++;
if(Mine[i][j-1].num==1)
nNUM++;
if(Mine[i][j+1].num==1)
nNUM++;
if(Mine[i-1][j-1].num==1)
nNUM++;
if(Mine[i-1][j+1].num==1)
nNUM++;
}
else/*普通格子的統計*/
{
if(Mine[i-1][j].num==1)
nNUM++;
if(Mine[i-1][j+1].num==1)
nNUM++;
if(Mine[i][j+1].num==1)
nNUM++;
if(Mine[i+1][j+1].num==1)
nNUM++;
if(Mine[i+1][j].num==1)
nNUM++;
if(Mine[i+1][j-1].num==1)
nNUM++;
if(Mine[i][j-1].num==1)
nNUM++;
if(Mine[i-1][j-1].num==1)
nNUM++;
}__page_break__
return(nNUM);/*把格子周圍一共有多少雷數的統計結果返回*/
}
int ShowWhite(int i,int j)/*顯示無雷區的空白部分*/
{
if(Mine[i][j].flag==1||Mine[i][j].num==0)/*如果有紅旗或該格處理過就不對該格進行任何判斷*/
return;
mineNUM--;/*顯示過數字或者空格的格子就表示多處理了一個格子,當所有格子都處理過了表示勝利*/
if(Mine[i][j].roundnum==0&&Mine[i][j].num!=1)/*顯示空格*/
{
DrawEmpty(i,j,1,7);
Mine[i][j].num=0;
}
else
if(Mine[i][j].roundnum!=0)/*輸出雷數*/
{
DrawEmpty(i,j,0,8);
sprintf(randmineNUM,"%d",Mine[i][j].roundnum);
setcolor(RED);
outtextxy(195+j*20,95+i*20,randmineNUM);
Mine[i][j].num=0;/*已經輸出雷數的格子用0表示已經用過這個格子*/
return ;
}
/*8個方向遞歸顯示所有的空白格子*/
if(i!=0&&Mine[i-1][j].num!=1)
ShowWhite(i-1,j);
if(i!=0&&j!=9&&Mine[i-1][j+1].num!=1)
ShowWhite(i-1,j+1);
if(j!=9&&Mine[i][j+1].num!=1)
ShowWhite(i,j+1);
if(j!=9&&i!=9&&Mine[i+1][j+1].num!=1)
ShowWhite(i+1,j+1);
if(i!=9&&Mine[i+1][j].num!=1)
ShowWhite(i+1,j);
if(i!=9&&j!=0&&Mine[i+1][j-1].num!=1)
ShowWhite(i+1,j-1);
if(j!=0&&Mine[i][j-1].num!=1)
ShowWhite(i,j-1);
if(i!=0&&j!=0&&Mine[i-1][j-1].num!=1)
ShowWhite(i-1,j-1);
}
void GamePlay(void)/*游戲過程*/
{
int i,j,Num;/*Num用來接收統計函數返回一個格子周圍有多少地雷*/
for(i=0;i<10;i++)
for(j=0;j<10;j++)
Mine[i][j].roundnum=MineStatistics(i,j);/*統計每個格子周圍有多少地雷*/
while(!kbhit())
{
if(LeftPress())/*滑鼠左鍵盤按下*/
{
MouseGetXY();
if(MouseX>280&&MouseX<300&&MouseY>65&&MouseY<85)/*重新來*/
{
MouseOff();
gameAGAIN=1;
break;
}
if(MouseX>190&&MouseX<390&&MouseY>90&&MouseY<290)/*當前滑鼠位置在格子范圍內*/
{
j=(MouseX-190)/20;/*x坐標*/
i=(MouseY-90)/20;/*y坐標*/
if(Mine[i][j].flag==1)/*如果格子有紅旗則左鍵無效*/
continue;
if(Mine[i][j].num!=0)/*如果格子沒有處理過*/
{
if(Mine[i][j].num==1)/*滑鼠按下的格子是地雷*/
{
MouseOff();
GameOver();/*游戲失敗*/
break;
}
else/*滑鼠按下的格子不是地雷*/
{
MouseOff();
Num=MineStatistics(i,j);
if(Num==0)/*周圍沒地雷就用遞歸演算法來顯示空白格子*/
ShowWhite(i,j);
else/*按下格子周圍有地雷*/
{
sprintf(randmineNUM,"%d",Num);/*輸出當前格子周圍的雷數*/
setcolor(RED);
outtextxy(195+j*20,95+i*20,randmineNUM);
mineNUM--;
}
MouseOn();
Mine[i][j].num=0;/*點過的格子周圍雷數的數字變為0表示這個格子已經用過*/
if(mineNUM<1)/*勝利了*/
{
GameWin();
break;
}
}
}
}
}
if(RightPress())/*滑鼠右鍵鍵盤按下*/
{
MouseGetXY();
if(MouseX>190&&MouseX<390&&MouseY>90&&MouseY<290)/*當前滑鼠位置在格子范圍內*/
{
j=(MouseX-190)/20;/*x坐標*/
i=(MouseY-90)/20;/*y坐標*/
MouseOff();
if(Mine[i][j].flag==0&&Mine[i][j].num!=0)/*本來沒紅旗現在顯示紅旗*/
{
DrawRedflag(i,j);
Mine[i][j].flag=1;
}
else
if(Mine[i][j].flag==1)/*有紅旗標志再按右鍵就紅旗消失*/
{
DrawEmpty(i,j,0,8);
Mine[i][j].flag=0;
}
}
MouseOn();
sleep(1);
}
}
}

❾ 編譯.c文件小游戲

摘要 首先當然是要確定你對於C++的核心語法有著比較深刻的理解了,比如對於面向對象編程的多態,虛函數等等,還有C/C++的指針,要能做到熟練運用的地步。這里並不是說你知道如何寫一個類,知道如何創建一個指針,而是要能理順幾個類甚至十幾個類之間的關系,因為做一個完整的小游戲需要各個不同的類之間有錯綜復雜的繼承關系,如果不能理清這些,那到時候就真的是剪不斷理還亂了。

❿ 給我一個用free pascal編譯的游戲程序

program xcvbn;
var
plife,plifemax,patt,pre:integer;
gr,ex,exmax:integer;
alife,alife1,aatt,are:integer;
name,fname:string;
na:text;
code,co:string;
dz:integer;
money:longint;
mp,mpmax:integer;
red,blue,knife,clothes:integer;
i:integer;
god:array[1..100] of 1..7;
godthing:integer;
procere bag;
var
obj:integer;
begin
writeln;
writeln;
writeln('百寶箱:');
writeln('1:紅色葯丸: ',red,' 2:蘭色葯丸: ',blue,' 3:神劍:',knife,' 4:防身衣:',clothes,' 5;離開');
writeln;
writeln;
writeln('請選擇:');
repeat
readln( obj);
case obj of
1:begin
if red>0 then begin
red:=red-1;
plife:=plife+40;
if plife>plifemax then plife:=plifemax;
end;
end;
2:begin
if blue>0 then begin
blue:=blue-1;
mp:=mp+40;
if mp>mpmax then mp:=mpmax;
end;
end;

3:begin
if knife>0 then begin
knife:=knife-1;
patt:=patt+15;
end;
end;
4:begin
if clothes>0 then begin
clothes:=clothes-1;
pre:=pre+15;
end;
end;
end;
writeln;
writeln;
writeln;
until obj=5;
exit;
end;

procere bagplus(sh:integer);
begin
case sh of
1:red:=red+1;
2:blue:=blue+1;
3:knife:=knife+1;
4:clothes:=clothes+1;
end;
end;

procere shop;
var
ob:integer;
begin
writeln;
writeln;
writeln('歡迎來到商店!');
writeln(' 1:紅色葯丸 2:蘭色葯丸 3:神劍 4:防身衣 5:離開');
writeln(' $15 $15 $30 $30');
writeln;
writeln('你想買什麼?');
writeln;
repeat
readln(ob);
case ob of
1:begin
if money>=15 then
begin
money:=money-15;
bagplus(1);
writeln('OK!');
writeln(' 1:紅色葯丸 2:蘭色葯丸 3:神劍 4:防身衣 5:離開');
writeln(' $15 $15 $30 $30');
writeln;
writeln('你想買什麼?');
writeln;
end
else writeln('錢不夠啊,老大!');
end;
2:begin
if money>=15 then
begin
money:=money-15;
bagplus(2);
writeln('OK!');
writeln(' 1:紅色葯丸 2:蘭色葯丸 3:神劍 4:防身衣 5:離開');
writeln(' $15 $15 $30 $30');
writeln;
writeln('你想買什麼?');
writeln;
end
else writeln('錢不夠啊,老大!');
end;

3:begin
if money>=30 then
begin
money:=money-30;
bagplus(3);
writeln('OK!');
writeln(' 1:紅色葯丸 2:蘭色葯丸 3:神劍 4:防身衣 5:離開');
writeln(' $15 $15 $30 $30');
writeln;
writeln('你想買什麼?');
writeln;
end
else writeln('錢不夠啊,老大!');
end;

4:begin
if money>=30 then
begin
money:=money-30;
bagplus(4);
writeln('OK!');
writeln(' 1:紅色葯丸 2:蘭色葯丸 3:神劍 4:防身衣 5:離開');
writeln(' $15 $15 $30 $30');
writeln;
writeln('你想買什麼?');
writeln;
end
else writeln('錢不夠啊,老大!');
end;

end;
until ob=5;
exit;
end;

procere storm;
var
ka,kp:integer;
begin
if mp>=30 then begin
writeln;
writeln;
writeln('破天一劍!!!!!!!!!!');

writeln(' 怪物生命:',alife1);
writeln('你的生命:',plife,'/',plifemax);
kp:=(random(patt)-random(are))*33; ;
if kp>0 then begin
writeln('攻擊!!怪物得到',kp,' 傷害!?!');
alife1:=alife1-kp;
end
else begin
writeln('你無法攻擊');
end;
ka:=aatt-pre+random(aatt div 4)-aatt div 2;
if ka>0 then begin
writeln('怪物攻擊!!你得到',ka,' 傷害!?!');
plife:=plife-ka;
end
else begin
writeln( ' 怪物無法攻擊');
end;
mp:=mp-30;
end
else writeln('魔力不夠!!');
end;

procere wall;
var
ka,kp:integer;
begin
if mp>=15 then begin
writeln;
writeln;
writeln('你用雷光!!!!');
writeln('怪物生命:',alife1);
writeln('你的生命:',plife,'/',plifemax);
kp:=(random(patt)-random(are))*26;
if kp>0 then begin
writeln('攻擊!!怪物得到',kp,' 傷害!?!');
alife1:=alife1-kp;
end
else begin
writeln('你輸了');
end;
ka:=aatt-pre+random(aatt div 4)-aatt div 2;
if ka>0 then begin
writeln('怪物攻擊!!你得到',ka,' 傷害!?!');
plife:=plife-ka;
end
else begin
writeln( ' 你贏了!!!!!');
end;
mp:=mp-10;
end
else writeln('生命不夠!!');
end;

procere ball;
var
ka,kp:integer;
begin
if mp>=5 then begin
writeln;
writeln;
writeln('你用粉碎神拳!!!');
writeln('怪物生命:',alife1);
writeln('你的生命:',plife,'/',plifemax);
kp:=(random(patt)-random(are))*20;
if kp>0 then begin
writeln('攻擊!!怪物得到',kp,' 傷害!?!');
alife1:=alife1-kp;
end
else begin
writeln('你輸了');
end;
ka:=aatt-pre+random(aatt div 4)-aatt div 2;
if ka>0 then begin
writeln('怪物攻擊!!你得到',ka,' 傷害!?!');
plife:=plife-ka;
end
else begin
writeln( ' 你贏了!!!!!');
end;
mp:=mp-10;
end
else writeln('生命不夠!!');
end;

procere magic;
var
ma:integer;

begin
writeln;
writeln;
writeln('1. 粉碎神拳 [5] 2. 雷光 [15] 3.破天一劍 [30]');
writeln('魔法值: ',mp,'/',mpmax);
read(ma);
case ma of
1:ball;
2:wall;
3:storm;
end;
end;

procere plusmoney;
var
money1:longint;
begin
money1:=random(alife);
writeln;
writeln;
writeln('你得到 $',money1);
money:=money1+money;
end;

procere load;
begin
close(na);
writeln;
writeln;
writeln('你的名字: ');
readln;
readln(name);
fname:=concat(name,'.txt');
assign(na,fname);
reset(na);
readln(na,code);
writeln('輸入密碼:');
readln(co);
if co<>code then
begin
writeln('密碼錯誤');
readln;
halt;
end;
readln(na,plife);
readln(na,plifemax);
readln(na,patt);
readln(na,pre);
readln(na,ex);
readln(na,exmax);
readln(na,gr);
readln(na,money);
readln(na,mp);
readln(na,mpmax);
readln(na,red);
readln(na,blue);
readln(na,knife);
readln(na,clothes);

end;

procere save;
var i:integer;
begin
close(na);
assign(na,fname);
rewrite(na);
writeln(na,code);
writeln(na,plife);
writeln(na,plifemax);
writeln(na,patt);
writeln(na,pre);
writeln(na,ex);
writeln(na,exmax);
writeln(na,gr);
writeln(na,money);
writeln(na,mp);
writeln(na,mpmax);
writeln(na,red);
writeln(na,blue);
writeln(na,knife);
writeln(na,clothes);
writeln(na,godthing);
for i:=1 to godthing do writeln(god[i]);
writeln;
writeln;
writeln('save successfully');
writeln;
writeln;
end;

procere see;var i:integer;
begin
writeln('你的名字: ',name);
writeln('你的生命: ',plife,'/',plifemax);
writeln('攻擊力: ',patt);
writeln('防禦力: ',pre);
writeln('經驗: ',ex);
writeln('升級經驗',exmax);
writeln('級數: ',gr);
writeln('鈔票:',money);
writeln('魔力: ',mp,'/',mpmax);
write('光之七神器:');for i:=1 to godthing do write(god[i],' ');
writeln;
writeln('百寶箱:');
writeln('紅色葯丸:',red);
writeln('蘭色葯丸:',blue);
writeln('神劍:' ,knife);
writeln('防身衣:',clothes);
writeln;
writeln;

end;

procere people;
begin
plife:=100;
plifemax:=100;
patt:=20;
pre:=15;
money:=100;
gr:=1;
ex:=0;
exmax:=20;
mp:=50;
mpmax:=50;
red:=5;
blue:=5;
knife:=0;
clothes:=0;
end;

procere old;
var i:integer;
begin
writeln('輸入你的名字 :');
readln;
readln(name);
fname:=concat(name,'.txt');
assign(na,fname);
reset(na);
readln(na,code);
writeln('輸入密碼:');
readln(co);
if co<>code then
begin
writeln('密碼錯誤!');
readln;
halt;
end;
readln(na,plife);
readln(na,plifemax);
readln(na,patt);
readln(na,pre);
readln(na,ex);
readln(na,exmax);
readln(na,gr);
readln(na,money);
readln(na,mp);
readln(na,mpmax);
readln(na,red);
readln(na,blue);
readln(na,knife);
readln(na,clothes);
readln(na,godthing);
for i:=1 to godthing do readln(god[i]);
end;

procere new;
var i:integer;
begin
writeln( ' 輸入你的名字: ');
readln;
readln(name);
if name<>'0' then begin
fname:=concat(name,'.txt');
assign(na,fname);
rewrite(na);
writeln('輸入密碼');
readln(code);
writeln(na,code);
people;
writeln(na,plife);
writeln(na,plifemax);
writeln(na,patt);
writeln(na,pre);
writeln(na,ex);
writeln(na,exmax);
writeln(na,gr);
writeln(na,money);
writeln(na,mp);
writeln(na,mpmax);
writeln(na,red);
writeln(na,blue);
writeln(na,knife);
writeln(na,clothes);
writeln(godthing);
for i:=1 to godthing do writeln(god[i]);
end
else halt;
end;

procere denlu;
var
dl:byte;
begin
writeln('-------------------自製的游戲不要笑----------------------');
writeln('-----------------------僅供娛樂----------------------');

writeln('1: 新游戲 2:老游戲 3:退出');
read(dl);
case dl of
1:new;
2:old;
3:halt;
end;
end;

procere godthing2;
var
qi:integer;
begin
randomize;
qi:=random(50);
case qi of
0,8:begin
writeln('得到光之七神具----1:辟天寶劍');
writeln('攻擊增加60點!!!');
patt:=patt+60;
godthing:=godthing+1;
god[godthing]:=1;
end;
3,16:begin
writeln('得到光之七神具----2:開地玄遠劍');
writeln('攻擊力*2');
patt:=patt*2;
godthing:=godthing+1;
god[godthing]:=2;
end;
end;
end;

procere grow;

begin

if ex>=exmax then begin
plife:=plifemax+50;
plifemax:=plife;
patt:=patt+15;
pre:=pre+15;
mpmax:=mpmax+30;
mp:=mpmax;
ex:=0;
gr:=gr+1;
exmax:=exmax+100;
writeln('升級!!');
godthing2;
writeln;
writeln;
end;
end;

procere experience;
begin
randomize;
ex:=ex+random(alife)+30;
grow;
end;

procere attack;
var
win,lost,run:boolean;
ch,ff,kp,ka:integer;
procere winner;
begin
win:=false;
if alife1<1 then win :=true;
end;
procere loster;
begin
lost:=false;
if plife<1 then lost:=true;
end;

begin
win:=false;
lost:=false;
run:=false;
writeln('1:攻擊; 2:逃跑');
writeln('你的生命:',plife,'/',plifemax);
writeln('你的魔法值: ',mp,'/',mpmax);
readln(ch);
if ch=1 then begin
alife1:=alife;
repeat
writeln;
writeln;
writeln('1:物理¥攻擊; 2:魔法¥攻擊; 3:用百寶箱; 4.逃跑 ');
read(ff);
case ff of
1:begin
writeln;
writeln;
writeln;
writeln;
{}
kp:=random(patt)-random(are);
if kp>0 then begin
writeln('你攻擊!!怪物受到',kp,' 傷害');
alife1:=alife1-kp;
end
else begin
writeln('你輸了');
end;
ka:=random(aatt)-random(pre);
if ka>0 then begin
writeln('怪物攻擊,你得到',ka,' 傷害');
plife:=plife-ka;
end
else begin
writeln( '怪物輸了');
end;
writeln(' 怪物生命:',alife1);
writeln('你生命:',plife,'/',plifemax);
writeln('你的魔法值: ',mp,'/',mpmax);
end;
2:begin
magic;
end;
3:begin
bag;
end;
4:begin
run:=true;
writeln('逃跑失敗');
end;
end;
winner;
loster;

until win or lost or run;
if win then begin experience; plusmoney; writeln('你贏了!!!'); writeln; end;
if lost then
begin
writeln('輸了');
readln;
halt;
end;
end
else exit;
end;

procere animal;
begin
alife:=plifemax+random(50);
if plifemax=100 then begin
aatt:=15;
are:=10;
end
else begin
aatt:=aatt+10;
are:=are+7;
end;
attack;
end;

procere meet;
var
cc:integer;
begin
randomize;
cc:=random(100);
if cc<40 then begin
writeln;
writeln('你遇見一個怪物');
animal;
end
else writeln('沒碰到.......');
end;

procere choose;

begin
writeln('1:找怪物; 2:去商店; 3:讀取; 4:保存; 5:退出 6:查看 7:用百寶箱');
read(dz);
case dz of
1:meet;
2:shop;
3:load;
4:save;
6:see;
7:bag;
end;
end;
begin
denlu;
while dz<>5 do
choose;
close(na);
end.
魔獸

閱讀全文

與編譯游戲大全相關的資料

熱點內容
噴油螺桿製冷壓縮機 瀏覽:579
python員工信息登記表 瀏覽:377
高中美術pdf 瀏覽:161
java實現排列 瀏覽:513
javavector的用法 瀏覽:982
osi實現加密的三層 瀏覽:233
大眾寶來原廠中控如何安裝app 瀏覽:916
linux內核根文件系統 瀏覽:243
3d的命令面板不見了 瀏覽:526
武漢理工大學伺服器ip地址 瀏覽:149
亞馬遜雲伺服器登錄 瀏覽:525
安卓手機如何進行文件處理 瀏覽:71
mysql執行系統命令 瀏覽:930
php支持curlhttps 瀏覽:143
新預演算法責任 瀏覽:444
伺服器如何處理5萬人同時在線 瀏覽:251
哈夫曼編碼數據壓縮 瀏覽:426
鎖定伺服器是什麼意思 瀏覽:385
場景檢測演算法 瀏覽:617
解壓手機軟體觸屏 瀏覽:350