在好例子网,分享、交流、成长!
您当前所在位置:首页C/C++ 开发实例C/C++游戏开发 → 三国杀小游戏源码(c++入门)

三国杀小游戏源码(c++入门)

C/C++游戏开发

下载此实例
  • 开发语言:C/C++
  • 实例大小:0.05M
  • 下载次数:38
  • 浏览次数:1116
  • 发布时间:2018-10-05
  • 实例类别:C/C++游戏开发
  • 发 布 人:CHNERUIJIE
  • 文件格式:.cpp
  • 所需积分:3
 相关标签: 三国杀

实例介绍

【实例简介】

【实例截图】

from clipboard

【核心代码】


#include<iostream>
#include<time.h>
#include<stdio.h>
#include <stdlib.h>
using namespace std;
struct pai
{
int paifu;
int huase;
int yanse;
int dianshu;
int leixing;
int changdu;
void Kanpai()
{
if(paifu==0||paifu==1);
else
printf("牌副参数错误!\n");
switch(huase)
{
case 0:cout<<"黑桃";break;
case 1:cout<<"红桃";break;
case 2:cout<<"草花";break;
case 3:cout<<"方片";break;
case -1:cout<<"无色";break;
default:printf("花色错误!\n");break;
}
switch(dianshu)
{
case 0:cout<<"A ";break;
case 1:cout<<"2 ";break;
case 2:cout<<"3 ";break;
case 3:cout<<"4 ";break;
case 4:cout<<"5 ";break;
case 5:cout<<"6 ";break;
case 6:cout<<"7 ";break;
case 7:cout<<"8 ";break;
case 8:cout<<"9 ";break;
case 9:cout<<"10 ";break;
case 10:cout<<"J ";break;
case 11:cout<<"Q ";break;
case 12:cout<<"K ";break;
case -1:cout<<"无点数";break;
default:printf("点数错误!\n");break;
}
switch(leixing)
{
case 101:cout<<"【杀】"<<endl;break;
case 102:cout<<"【闪】"<<endl;break;
case 103:cout<<"【桃】"<<endl;break;
case 201:cout<<"【过河拆桥】"<<endl;break;
case 202:cout<<"【顺手牵羊】"<<endl;break;
case 203:cout<<"【无中生有】"<<endl;break;
case 204:cout<<"【决斗】"<<endl;break;
case 205:cout<<"【借刀杀人】"<<endl;break;
case 206:cout<<"【桃园结义】"<<endl;break;
case 207:cout<<"【五谷丰登】"<<endl;break;
case 208:cout<<"【南蛮入侵】"<<endl;break;
case 209:cout<<"【万箭齐发】"<<endl;break;
case 210:cout<<"【无懈可击】"<<endl;break;
case 251:cout<<"【乐不思蜀】"<<endl;break;
case 252:cout<<"【闪电】"<<endl;break;
case 301:cout<<"【诸葛连弩(1)】"<<endl;break;
case 302:cout<<"【雌雄双股剑(2)】"<<endl;break;
case 303:cout<<"【青釭剑(2)】"<<endl;break;
case 304:cout<<"【青龙偃月刀(3)】"<<endl;break;
case 305:cout<<"【丈八蛇矛(3)】"<<endl;break;
case 306:cout<<"【贯石斧(3)】"<<endl;break;
case 307:cout<<"【方天画戟(4)】"<<endl;break;
case 308:cout<<"【麒麟弓(5)】"<<endl;break;
case 331:cout<<"【八卦阵】"<<endl;break;
case 361:cout<<"【赤兔(-1)】"<<endl;break;
case 362:cout<<"【大宛(-1)】"<<endl;break;
case 363:cout<<"【紫辛(-1)】"<<endl;break;
case 381:cout<<"【爪黄飞电( 1)】"<<endl;break;
case 382:cout<<"【的卢( 1)】"<<endl;break;
case 383:cout<<"【绝影( 1)】"<<endl;break;
default:printf("类型参数错误!");break;
}
}
};
void Qishixipai(pai A[2][4][13],pai paidui[104])
{
int i,m,x,y,z,a[104]={0};
srand((unsigned)time(NULL));
for(i=1;i<=104;i  )
{
while(a[m=rand()%104]);
a[m]=i;
}
for(i=0;i<=103;i  )
{
x=(a[i]-1)/52;
y=((a[i]-1)-52*x)/13;
z=(a[i]-1)%13;
paidui[i]=A[x][y][z];
}
}
void Xipai(pai paidui[104],int*paiduishu,pai qipaidui[104],int*qipaishu)
{
int i,m,a[104]={0};
srand((unsigned)time(NULL));
for(i=1;i<=(*qipaishu);i  )
{
while(a[m=rand()%(*qipaishu)]);
a[m]=i;
}
for(i=0;i<=((*qipaishu)-1);i  )
{
paidui[i]=qipaidui[a[i]];
qipaidui[a[i]].leixing=-1;
(*paiduishu)  ;
(*qipaishu)--;
}
for(i=(*paiduishu);i<=103;i  )paidui[i].leixing=-1;
}
pai Mo1pai(pai A[104],int *x,pai B[104],int*y,int *b)
{
pai p;
if((*x)==0)Xipai(A,x,B,y);
else if((*x)<0)printf("摸牌参数错误!");
else;
p=A[104-(*x)];
(*x)--;
(*b)  ;
return(p);
}
struct wujiang
{
char name;
int tili;
int tilishangxian;
int shoupaishangxian;
int huihekaishi;
int panding;
int mopai;
int chupai;
int qipai;
int huihejieshu;
int juese;
pai shoupai[20];
int shoupaishu;
pai zhuangbei[4];
int zhuangbeishu;
pai pandingpai[3];
int pandingshu;
int juli[1];
void Kanshoupai()
{
printf("玩家当前手牌:\n");
if(shoupaishu)
{
int m;
for(m=0;m<=(shoupaishu-1);m  )
{
printf("%d ",m);
(shoupai[m]).Kanpai();
}
}
else printf("空城!\n");
printf("\n");
}
void Kanzhuangbei()
{
if(juese)printf("玩家");
else printf("电脑");
printf("当前装备:\n");
printf("0 武器: ");
if((zhuangbei[0]).leixing==-1)printf("空\n");
else (zhuangbei[0]).Kanpai();
printf("1 防具: ");
if((zhuangbei[1]).leixing==-1)printf("空\n");
else (zhuangbei[1]).Kanpai();
printf("2 进攻马: ");
if((zhuangbei[2]).leixing==-1)printf("空\n");
else (zhuangbei[2]).Kanpai();
printf("3 防御马: ");
if((zhuangbei[3]).leixing==-1)printf("空\n");
else (zhuangbei[3]).Kanpai();
printf("\n");
}
void Kanpandingpai()
{
if(juese)printf("玩家");
else printf("电脑");
printf("当前判定区:\n");
if((pandingpai[0]).leixing==-1)printf("空\n");
else
{
printf("0 ");
(pandingpai[0]).Kanpai();
if((pandingpai[1]).leixing==-1);
else
{
printf("1 ");
(pandingpai[1]).Kanpai();
if((pandingpai[2]).leixing==-1);
else
{
printf("2 ");
(pandingpai[2]).Kanpai();
}
}
}
}
};
void Mopai(int*shoupaishu,pai shoupai[20],pai A[104],int *x,pai B[104],int*y,int juese)
{
if(juese)printf("玩家从牌堆摸2张牌\n");
else printf("电脑从牌堆摸2张牌\n");
pai p;
p=Mo1pai(A,x,B,y,shoupaishu);
shoupai[*shoupaishu-1]=p;
pai q;
q=Mo1pai(A,x,B,y,shoupaishu);
shoupai[*shoupaishu-1]=q;
int m;
if(juese)
{
printf("玩家当前手牌:\n");
for(m=0;m<=(*shoupaishu-1);m  )
{
printf("%d ",m);
(shoupai[m]).Kanpai();
}
}
printf("牌堆还剩%d张牌!\n\n",*x);
}
void Qishishoupai(wujiang *w,pai A[104],int *x,pai B[104],int*y)
{
pai a;
a=Mo1pai(A,x,B,y,&((*w).shoupaishu));
(*w).shoupai[(*w).shoupaishu-1]=a;
pai b;
b=Mo1pai(A,x,B,y,&((*w).shoupaishu));
(*w).shoupai[(*w).shoupaishu-1]=b;
pai c;
c=Mo1pai(A,x,B,y,&((*w).shoupaishu));
(*w).shoupai[(*w).shoupaishu-1]=c;
pai d;
d=Mo1pai(A,x,B,y,&((*w).shoupaishu));
(*w).shoupai[(*w).shoupaishu-1]=d;
int m;
if((*w).juese)printf("玩家从牌堆摸4张牌\n");
else printf("电脑从牌堆摸4张牌\n");
if((*w).juese)
{
printf("玩家当前手牌:\n");
for(m=0;m<=((*w).shoupaishu-1);m  )
{
printf("%d ",m);
((*w).shoupai[m]).Kanpai();
}
}
printf("牌堆还剩%d张牌!\n\n",*x);
}

标签: 三国杀

实例下载地址

三国杀小游戏源码(c++入门)

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警