游戏系列~拳皇
Posted yszhyhm
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了游戏系列~拳皇相关的知识,希望对你有一定的参考价值。
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>
#include<conio.h>
#define N 100
int n=0;
int Checktoseek(char name[]);//查找
void mainmenu();//菜单
void Register();//登记注册
void Showplayer();//显示当前人物数据
void Showallplayer();//显示所有人物数据
void Chooseopponent();//选择对手
void Chooseplayer(int i);//选择角色
void vs(int i,int j);//PK
void Attack(int i,int j);//攻击
void recovery(int i,int j);//防御
void Energy(int i,int j);//能量
struct Kof
{
char name[20];
int Hp;
int AP;
int Dp;
int Rp;
}player[N];
int main()
{
srand(unsigned(time(NULL)));
mainmenu();
}
void login()
{
}
void mainmenu()
{
while(1)
{
int x;
printf("\n");
printf("\n");
printf(" ***************************************************************\n");
printf(" *** ***\n");
printf(" *** ***\n");
printf(" *** 欢迎进入Kof ***\n");
printf(" *** ***\n");
printf(" *** ***\n");
printf(" ***************************************************************\n");
printf("\n\n\t\t\t\t\t=======选择项=======");
printf("\n\t\t\t\t\t||1----注册 ||\n");
printf("\t\t\t\t\t||2----查看玩家信息||\n");
printf("\t\t\t\t\t||3----查看自己信息||\n");
printf("\t\t\t\t\t||4----选择对手 ||\n");
printf("\t\t\t\t\t||5----结束 ||\n");
printf("\t\t\t\t\t=====================\n\n");
printf("\n\n请选择菜单:");
scanf("%d",&x);
if(x==5) break;
switch(x)
{
case 1:Register();break;
case 2:Showallplayer();break;
case 3:Showplayer();break;
case 4:Chooseopponent();break;
}
printf("\n\n\n\n\n按任意键继续:");
getch();
system("cls");
}
}
void Register()
{
char name[20];
printf("输入名称:");
fflush(stdin);
gets(name);
if(Checktoseek(name)==-1)
{
strcpy(player[n].name,name);
player[n].Hp=rand()%1000;
player[n].AP=rand()%(100+1)+50;
player[n].Dp=rand()%(10-5+2)+5;
player[n].Rp=rand()%(60+2)+60;
n++;
printf("人物创建成功\n");
}
else
{
Register();
}
}
void Showplayer()
{
char name[20];
printf("角色名:");
fflush(stdin);
gets(name);
int i=Checktoseek(name);
if(i!=-1)
{
printf("人物名称:%s\n",player[i].name);
printf("Hp:%d\n",player[i].Hp);
printf("Ap:%d\n",player[i].AP);
printf("Dp:%d\n",player[i].Dp);
printf("Rp:%d\n",player[i].Rp);
}
else
{
printf("请重新输入角色名");
Showplayer();
}
}
void Showallplayer()
{
printf("%-10s%-10s%-10s%-10s%-10s\n","Name","Hp","Ap","Dp","Rp");
for(int i=0;i<n;i++)
{
printf("%-10s%-10d%-10d%-10d%-10d\n",player[i].name,player[i].Hp,player[i].AP,player[i].Dp,player[i].Rp);
}
}
void Chooseopponent()
{
char name[20];
int i;
Showallplayer();
printf("你选择PK谁:");
fflush(stdin);
gets(name);
i=Checktoseek(name);
if(i!=-1)
{
Chooseplayer(i);
}
else
{
printf("你选择PK的人物找不到?\n");
Chooseopponent();
}
}
int Checktoseek(char name[])
{
for(int i=0;i<n;i++)
{
if(!strcmp(player[i].name,name))
{
return i;
}
}
return -1;
}
void Chooseplayer(int i)
{
char name[20];
int j;
printf("请你选择一个角色:");
fflush(stdin);
gets(name);
j=Checktoseek(name);
if(j!=-1 && j!=i)
{
vs(i,j);
}
else
{
Chooseplayer(i);
}
printf("=================================\n");
}
void vs(int i,int j)
{
int count=1;
while(player[i].Hp>0 && player[j].Hp>0)
{
printf("==================第%d局==================\n\n",count);
if(count%2==0)
{
Attack(i,j);
recovery(i,j);
Energy(i,j);
}
else
{
Attack(j,i);
recovery(i,j);
Energy(i,j);
}
count++;
_sleep(3344);
}
if(player[i].Hp>0)
{
printf("%s 获得了胜利 \n",player[i].name);
}
else
{
printf("%s 获得了胜利 \n",player[j].name);
}
printf("******************************\n");
}
void Attack(int i,int j)
{
int x;
int s;
x=rand()%5;
switch(x)
{
case 0:
printf("\n%s发出波动伤害%s\n",player[i].name,player[j].name);
s=rand()%100;
player[j].Hp-=s;
printf("%s受到%d点伤害\n\n",player[j].name,s);
break;
case 1:
printf("\n%s使用连招攻击%s\n",player[i].name,player[j].name);
s=rand()%100*2;
player[j].Hp-=s;
printf("%s受到%d点伤害\n\n",player[j].name,s);
break;
case 2:
printf("\n%s释放超杀技\n",player[i].name);
s=(rand()%100)*4;
player[j].Hp-=s;
printf("%s受到%d点伤害\n\n",player[j].name,s);
break;
}
}
void recovery(int i,int j)
{
int s;
int x;
s=rand()%3;
switch(s)
{
case 0:
printf("\n%s防御%s的攻击\n",player[i].name,player[j].name);
x=rand()%(10-5+2)+5;
player[i].Dp==x;
printf("%s抵挡%d点伤害\n\n",player[i].name,x);
break;
case 1:
printf("\n%s防御%s的攻击\n",player[j].name,player[i].name);
x=rand()%(10-5+2)+5;
player[j].Dp==x;
printf("%s抵挡%d点伤害\n\n",player[j].name,x);
break;
}
}
void Energy(int i,int j)
{
int x;
int s;
x=rand()%6;
switch(x)
{
case 0:
printf("\n%s大怒,使用超必杀技\n",player[i].name);
s=(rand()%100)*6;
player[j].Hp-=s;
printf("%s受到%d点伤害\n\n",player[j].name,s);
break;
case 1:
printf("\n%s大怒,使用超必杀技\n",player[j].name);
s=(rand()%100)*6;
player[i].Hp-=s;
printf("%s受到%d点伤害\n\n",player[i].name,s);
break;
}
}
以上是关于游戏系列~拳皇的主要内容,如果未能解决你的问题,请参考以下文章
今日说法播报steam库存案件,沙特王储因为喜欢拳皇收购了SNK,免费领狂怒2,P社在steam推出DLC订阅服务
我用Python训练了一个拳皇模型,从此在各地游戏厅再也没输过!