#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
#include <string.h>
#include <time.h>
#include <conio.h>
int Map[12][30]={0};
char No1[12],No2[12];
int stepp[101],fi=0,sr=0;
//////////////////////////////////////
void drawHead();/////游戏顶部信息
void begin();//程序开始
void initMap();//人物选择
void doType();//玩家操作选择
int randoms(int,int);//伪随机数生成方法
void infos();//使用说明书信息
void randList();//地图随机化
void createMap();//创建地图
void printfMap();//打印地图
void start();//开始游戏
int judge();//判断脚下
int qianru(int);
void play();
void change();//地图转换
void back();//退回
int no1(int);//第一玩家
int no2(int);//第二个玩家
int fist();
int send();
void jiance();
void ini();
////////////////////////////////////////
int main()
{
begin();
createMap();//创立地图
change();//地图转换
printfMap();//打印地图
start();
return 0;
}
//system("cls");
//进入游戏
void start()
{
int i,k;
while(1)
{
i=fist();///////////////////////////////
if(i==2)
break;
back();//重新塑图
printfMap();//打印地图
k=send();/////////////////////////////
if(k==2)
break;
back();//重新塑图
printfMap();//打印地图
}
}
//
int fist()
{
int n,step;
char h;
printf("请%s按键继续:\n",No1);
h=getch();
system("cls");
step=randoms(1,6);
n=no1(step);
if(n==2)
{
printf("恭喜玩家1获胜!");
return 2;
}
else
return 1;
}
int send()
{
int n,step;
char h;
printf("请%s按键继续:\n",No2);
h=getch();
getch();
system("cls");
step=randoms(1,6);
n=no2(step);
if(n==2)
{
printf("恭喜玩家2获胜!");
return 2;
}
else
return 1;
}
//判断脚下
//第一个
int no1(int n)
{
int i,k;
fi+=n;
if(fi>=99)
return 2;
else
{
printf("玩家1进%d步。\n",n);
if(stepp[fi]==1)
{
stepp[fi]=6;
stepp[fi-n]=1;
return 1;
}
else if(stepp[fi]==2)
{
printf("恭喜您遇到幸运大转盘,");
stepp[fi-n]=1;
i=randoms(1,2);
if(i==1)
{
printf("退8步。\n");
if(fi-8>0)
{
stepp[fi-n]=1;
no1(-8);
}
else
{ stepp[fi]=1;
fi=0;
stepp[fi]=6;
}
return 1;
}
else if(i==3)
{
printf("玩家互换。\n");
k=sr;
fi=sr;
sr=k;
stepp[fi]=6;
stepp[sr]=7;
return 1;
}
else if(i==2)
{
printf("进10步。\n");
stepp[fi]=1;
no1(10);
stepp[fi]=6;
return 1;
}
}
else if(stepp[fi]==3)
{
printf("您不幸踩到地雷,退6步。\n");
if(fi-6>0)
{
stepp[fi-n]=1;
no1(-6);
}
else
{
stepp[fi]=1;
fi=0;
stepp[fi]=6;
}
return 1;
}
else if(stepp[fi]==4)
{
printf("您暂停一次。\n");
stepp[fi]=6;
stepp[fi-n]=1;
send();
return 1;
}
else if(stepp[fi]==5)
{
printf("恭喜玩家进入时空隧道。\n");
stepp[fi-n]=1;
no1(10);
// stepp[fi]=6;
return 1;
}
else if(stepp[fi]==7)
{
printf("恭喜玩家把对手踩回原点。\n");
sr=0;
stepp[sr]=7;
stepp[fi]=6;
stepp[fi-n]=1;
return 1;
}
}
}
//第二个
int no2(int n)
{
int i,k;
sr+=n;
if(sr>=99)
return 2;
else
{
printf("玩家2进%d步。\n",n);
if(stepp[sr]==1)
{
stepp[sr]=7;
stepp[sr-n]=1;
return 1;
}
else if(stepp[sr]==2)
{
printf("恭喜您遇到幸运大转盘,");
stepp[sr]=1;
i=randoms(1,3);
if(i==1)
{
printf("退8步。");
if(sr-8>0)
{
stepp[sr-n]=1;
no2(-8);
}
else
{
stepp[sr]=1;
sr=0;
stepp[sr]=7;
}
return 1;
}
else if(i==2)
{
printf("玩家互换。\n");
k=sr;
fi=sr;
sr=k;
stepp[fi]=6;
stepp[sr]=7;
return 1;
}
else if(i==3)
{
printf("进10步。\n");
stepp[sr-n]=1;
no2(10);
//stepp[sr]=7;
return 1;
}
}
else if(stepp[sr]==3)
{
printf("您不幸踩到地雷,退6步。\n");
if(sr-6>0)
{
stepp[sr-n]=1;
no2(-6);
}
else
{
stepp[sr]=1;
sr=0;
stepp[sr]=7;
return 1;
}
}
else if(stepp[sr]==4)
{
printf("您暂停一次。\n");
stepp[sr]=7;
stepp[sr-n]=1;
fist();
return 1;
}
else if(stepp[sr]==5)
{
printf("恭喜玩家进入时空隧道。\n");
stepp[sr-n]=1;
no2(10);
//stepp[sr]=7;
return 1;
}
else if(stepp[sr]==6)
{
printf("恭喜玩家把对手踩回原点。\n");
fi=0;
stepp[fi]=0;
stepp[sr]=7;
return 1;
}
}
}
//转换地图
void change()
{
int i,j,k;
for(i=0;i<30;i++)
stepp[i]=Map[0][i];
for(j=i+1;j<35;j++)
stepp[j]=Map[j-i][29];
for(k=0;k<30;k++)
stepp[35+k]=Map[6][29-k];
for(k=0;k<4;k++)
stepp[66+k]=Map[7+k][0];
for(k=0;k<30;k++)
stepp[69+k]=Map[11][k];
}
//开始
void begin()
{
char choice;
drawHead();
printf("是否进入游戏(y/n)?\n");
choice=getch();
if (choice=='y')
initMap();
//else
//exits();
}
//欢迎界面
void drawHead()
{
printf("****************************************\n\n");
printf(" 骑 士 飞 行 棋 \n\n");
printf("****************************************\n\n");
}
//人物2选择
void initMap()
{
int i;
printf("是否查看说明?<y/n>\n");
char choice;
//printf("是否进入游戏(y/n)?\n");
choice=getch();
if (choice=='y')
ini();
printf("~~~~~~~~~~~~~~两人对战~~~~~~~~~~~~~~~\n\n");
printf("请选择角色:1曹操 2诸葛亮 3刘备 4周瑜\n");
printf("请玩家1选择:");
scanf("%d",&i);
if(i==1)
{
printf("玩家1姓名曹操,用①表示\n");
strcmp(No1,"曹操");
}
else if(i==2)
{
printf("玩家1姓名诸葛亮,用①表示\n");
strcmp(No1,"诸葛亮");
}
else if(i==3)
{
printf("玩家1姓名刘备,用①表示\n");
strcmp(No1,"刘备");
}
else
{
printf("玩家1姓名周瑜,用①表示\n");
strcmp(No1,"周瑜");
}
printf("请玩家2选择:");
scanf("%d",&i);
if(i==1)
{
printf("玩家2姓名曹操,用②表示\n");
strcmp(No2,"曹操");
}
else if(i==2)
{
printf("玩家2姓名诸葛亮,用②表示\n");
strcmp(No2,"诸葛亮");
}
else if(i==3)
{
printf("玩家2姓名刘备,用②表示\n");
strcmp(No2,"刘备");
}
else
{
printf("玩家2姓名周瑜,用②表示\n");
strcmp(No2,"周瑜");
}
}
////建立地图
void createMap()
{
int i;
for(i=0;i<30;i++)
{
Map[0][i]=1;
Map[6][i]=1;
Map[11][i]=1;
}
Map[1][29]=Map[2][29]=Map[3][29]=Map[4][29]=Map[5][29]=1;
Map[7][0]=Map[8][0]=Map[9][0]=Map[10][0]=1;
randList();
}
//打印地图
void printfMap()
{
int i,j;
for(i=0;i<12;i++)
{
for(j=0;j<30;j++)
{
if(Map[i][j]==0)
printf(" ");
else if(Map[i][j]==1)
printf("∷");
else if(Map[i][j]==2)
printf("¤");
else if(Map[i][j]
qishifeixingqi.zip_qishifeixingqi_飞行棋
版权申诉
159 浏览量
2022-09-19
20:28:38
上传
评论
收藏 3KB ZIP 举报
weixin_42651887
- 粉丝: 79
- 资源: 1万+
最新资源
- 本科毕业设计基于C# wpf人脸识别的考勤系统的设计与实现源码.zip
- 基于Ruoyi+uniapp实现学生考勤系统 学生考勤源码+项目说明.zip
- feae6bc968ca68a099455d8b8a8dea35
- 基于Pytorch训练CIRAR10上分类算法.zip
- Pytorch-pytorch深度学习教程之Tensorboard.zip
- 基于C++和Python开发yolov8-face作为人脸检测器dlib作为人脸识别器的人脸考勤系统源码+项目说明.zip
- Pytorch-pytorch深度学习教程之变分自动编码器.zip
- Pytorch-pytorch深度学习教程之神经风格迁移.zip
- Pytorch-pytorch深度学习教程之深度残差网络.zip
- Pytorch-pytorch深度学习教程之循环神经网络.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈