c语言游戏
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include
#include
#include
#include
#define byte unsigned char
void main()
{
void kaishi();//开场文字//
int huamian1( int mission);//画面1//
int huamian2(int mission);//画面2//
void shengli();//胜利//
void jieshu(char a[40],int b);//结束//
int i,j,k,m;
struct player
{
char name[40];
int mission;
}player;
printf("Input your name please\n");
scanf("%s",&);
Sleep(3000);
player.mission=1;
printf("\n\n\n");
kaishi();
Lab1:;
m=huamian1(player.mission);
if (m==1)
{
goto Lab6;
}
else if(player.mission<=8)
{
player.mission++;goto Lab1;
}
else goto Lab2;
Lab2:;
Sleep(2000);
printf("\n\n your eyes are pretty good on catching fast things,\n");
Sleep(1000);
printf("then what about changing the direction?\n\n");
player.mission++;
Lab3:;
m=huamian2(player.mission);
if (m==1)
{
goto Lab6;
}
else if(player.mission<=18)
{
player.mission++;
goto Lab3;
}
else goto Lab4;
Lab4:;
shengli();
Lab6:;
jieshu(,player.mission);
}
void kaishi()
{
int i;
char text1[15]="this is a game,";
char text2[41]="a,s,d,f are four ways to cross the river,";
char text3[34]="don't be knocked down by anything,";
char text4[11]="good luck !";
for (i=0;i<=14;i++)
{
if (text1[i]!=" ") Sleep(100);
printf("%c",text1[i]);
}
printf("\n");
Sleep(1000);
for (i=0;i<=40;i++)
{
if (text2[i]!=" ") Sleep(100);
printf("%c",text2[i]);
}
printf("\n");
Sleep(1000);
for (i=0;i<=33;i++)
{
if (text3[i]!=" ") Sleep(100);
printf("%c",text3[i]);
}
printf("\n");
Sleep(1000);
for (i=0;i<=10;i++)
{
if (text4[i]!=" ") Sleep(100);
printf("%c",text4[i]);
}
printf("\n\n\n");
Sleep(1000);
}
int huamian2(int mission)
{
int i,k,j,m;
char way;
char tem[80]=" 1111 1111 1111 ";
char tom[80]=" |A| |S| |D| |F| ";
printf("\n\n\n");
printf("Mission %d\n",mission);
Sleep(1000);
printf("%s",&tom[0]);
printf("\n");
Sleep(2000);
for(i=0;i<=1000;i=i+1)
{
while (!_kbhit())
{
{
printf("\r");
printf("%s", &tem[0]);
k=tem[20];
for(j=20;j<=42;j++)
{
tem[j]=tem[j+1];
}
tem[43]=k;
Sleep(380-mission*20);
}
}
}
if (kbhit())
{
way=getch();
if (way=='a')
{
if (tem[24]=='1')
{Sleep(2000);
printf("\n\n\n you just pressed %c!\n",way);
printf(" you are in the river !\n");m=1;
}
else {
printf("\n\n pass pass pass pass ");
m=0;
}
}
if (way=='s')
{
if (tem[29]=='1')
{Sleep(2000);
printf("\n\n\n you just pressed %c!\n",way);
printf(" you are in the river !\n");m=1;
}
else {
printf("\n\n pass pass pass pass ");
m=0;
}
}
if (way=='d')
{
if (tem[34]=='1')
{Sleep(2000);
printf("\n\n\n you just pressed %c!\n",way);
printf(" you are in the river !\n");m=1;
}
else {
printf("\n\n pass pass pass pass ");
m=0;
}
}
if (way=='f')
{
if (tem[39]=='1')
{Sleep(2000);
printf("\n\n\n you just pressed %c!\n",way);
printf(" you are in the river !\n");m=1;
}
else {
printf("\n\n pass pass pass pass ");
m=0;
}
}
}
return (m);
}
int huamian1(int mission)
{
int i,k,j,m;
char way;
char tem[80]=" 1111 1111 1111 ";
char tom[80]=" |A| |S| |D| |F| ";
printf("\n\n\n");
printf("Mission %d\n",mission);
Sleep(1000);
printf("%s",&tom[0]);
printf("\n");
Sleep(2000);
for(i=0;i<=1000;i=i+1)
{
while (!_kbhit())
{
{
printf("\r");
printf("%s", &tem[0]);
k=tem[43];
for(j=43;j>=21;j--)
{
tem[j]=tem[j-1];
}tem[20]=k;
Sleep(200-mission*20);
}
}
}
if (kbhit())
{
way=getch();
if (way=='a')
{
if (tem[24]=='1')
{Sleep(2000);
printf("\n\n\n you just pressed %c!\n",way);
printf(" you are in the river !\n");m=1;
}
else {
printf("\n\n pass pass pass pass ");
m=0;
}
}
if (way=='s')
{
if (tem[29]=='1')
{Sleep(2000);
printf("\n\n\n you just pressed %c!\n",way);
printf(" you are in the river !\n");m=1;
}
else {
printf("\n\n pass pass pass pass ");
m=0;
}
}
if (way=='d')
{
if (tem[34]=='1')
{Sleep(2000);
printf("\n\n\n you just pressed %c!\n",way);
printf(" you are in the river !\n");m=1;
}
else {
printf("\n\n pass pass pass pass ");
m=0;
}
}
if (way=='f')
{
if (tem[39]=='1')
{Sleep(2000);
printf("\n\n\n you just pressed %c!\n",way);
printf(" you are in the river !\n");m=1;
}
else {
printf("\n\n pass pass pass pass ");
m=0;
}
}
}
return (m);
}
void shengli()
{
Sleep(2000);
printf("\n* * *** *** ******* *** ***** * *");
printf("\n * * * * * * * * * * *");
printf("\n * * * * * * * ***** *");
printf("\n * * * * * * * * * *");
printf("\n * *** *** * *** * * *");
printf("\n\n\n");
printf("\n press any key to end the program of winner !!\n\n");
Sleep(4000);
while (!_kbhit())
{
_cputs(" you won ! ");Sleep(80);
}
if (kbhit()) ;
}
void jieshu(char a[40],int b)
{
Sle
ep(2000);
printf("\n\n\n %s is not a green hand !\n",&a[0]);
Sleep(2000);
printf(" because that guy has just finished Mission %d !",b-1);
Sleep(2000);
printf("\n\n\n thank you for your playing , have fun!\n\n");
}
//made by 东大电子1201老游