一个小的文字游戏【灭龙传说】
程序代码:
/*灭龙传说文字版 V2014.4.20.02 By WinKill*/ #include<stdio.h> #include<stdlib.h> #include<windows.h> #include<string.h> #include<conio.h> //引用 #define cls system("cls") //清屏 void ttdy(char main_t[],char m_title[],int clspa,int clspb,int timep,int ptime);//打印函数 void sttdy(char stt[],int timep,int ptime);//单一打印:打印字符、播放速度、暂停时间 void errdy(char etext[],char e_title[],char e_class[],int clsup);//错误提示:提示内容、提示标题、严重情况、清屏 void btdy(char btfh[],char bttitle[]);//标题打印函数:美化符号、标题 void gsdy(char gst[],int len);//打印间隔条 void main_dh(); void newgame(); void menuf(); void peoinfo(); void lookwep(); void wupin(); void usewp(int bhao); void shopc(); void wpinfo(int bhao); void buywp(int bhao);void pwp(int bhao);//商店、物品信息、买东西、卖东西 void cityc();void cityinfo(int bhao); void help_menu(); void small_game(); void upcheck(); void end_from_menu(); void skill(); void skillinfo(int bhao);void skdy(char skt[]); void gwinfo(int bhao); void god_here(); void pkload(int bhao);void pkwin(int bhao);void pklost(int bhao); void test(); //各功能函数 int shop_n,spn_a,spn_b,spn_c,spn_n,spback_n; //商店种类判断参数 int wpinfo_n,wpback_n=0,wp_run_n;//信息界面显示菜单值,1显示使用,2显示购买 int sp_a[10],sp_b[10],sp_c[10];//列表具体物品判定 int sk_n,skback_n=0,skill_n=0; //技能参数,返回值(0返回人物信息,1返回战斗), int pkmenu_n=0,here_ghp,pkstart=0;//PK菜单显示判断,0则显示返回,1则不能再返回。 int getgj,getfy,getspeed,getsk,gethp; int lgj=1,lfy=1,lspeed=1;//因技能产生的临时倍率 int lggj=1,lgfy=1,lgspeed=1;//因技能产生的怪物临时倍率 int getggj,getgfy,getgspeed,getgsk,getghp;//战斗必须参数 int cityk_n;//城市返回全局参数 char main_t[700]="自古就有想要屠龙的勇士,世间也流传着无数屠龙的传说!毫无疑问,能够成为屠龙之人,必定能够名动天下,流传千古。而《灭龙传说》的故事,就开始于屠龙,开始于你。。。"; char main_t_title[30]="《灭龙传说》游戏序V1.2"; char help_m[600]="本游戏十分简单,所有操作只需按选项之前的字母或者数字。作为一款文字游戏,本游戏没有华丽的图片和声音特效,只为交流编程技术,当你闯关完成后,将会获得本程序的源代码。注意,不要试图使用不正常方法通关哦!"; int main_pd=1,welcome_n=1;//开场动画播放判定 struct player{char name[20];int dj;int gj;int fy;int speed;int luck;int gold;int yesp;int exp;int exped;int hp;int hpmax;int mp;int mpmax;}gplay[10]; //角色数组:角色名,等级,攻击,防御,速度,幸运,金币,存在判断( 若yesp=99则判定用户已存在),经验,升级经验,血量和魔法值。 struct wp{char name[30];char pinzhi[20];int zyk;int jhp;int jmp;int jgj;int jfy;int jspeed;int jluck;int mgold;int nbag;int jbaoj;int haved;int mhave;int cbuy;int cshop;}gwp[]; //物品数组:物品名,品质,作用值,加血,加魔,加攻击,加防御,加速度,加幸运,价格,占用包裹,加暴击,拥有量,最大拥有,可买(1可买,0不可),可卖(1可)。 struct ct{char name[30];char info[100];int sgnum;int gnum;int ndj;}gct[]; //地图结构:地图名,简介;怪物起点,怪物数量,限制等级 struct gw{char name[30];char talk[200];int dj;int gj;int fy;int speed;int hp;int hpmax;int mp;int mpmax;int hexp;int hgold;int hyp;int hwp;int hqb;int allow_run;}ggw[]; //怪物结构:名称,交流,等级,攻击,防御,速度,血,最大血,魔,最大魔,携带经验,携带金币,随机奖励药品(1有),随机武器,随机奇宝,允许逃跑(1允许) struct skill{char name[50];char info[200];int keep;int jhp;int jgj;int jfy;int jspeed;int jluck;int nmp;int ndj;int allow_use;}gskill[]; //技能结构:名称,介绍,持续回合,加血,加攻击(百分比),加防御,加速度,加幸运,释放需要MP,限制等级,,允许释放(1允许), int c_play,c_gwp;//数组编号统计 struct wp gwp[200]={ {"小灵芝","低级★",1,50,0,0,0,0,0,20,1,0,3,99,1,1}, {"中灵芝","中级★★",1,100,0,0,0,0,0,40,2,0,1,99,1,1}, {"大灵芝","高级★★★",1,200,0,0,0,0,0,80,3,0,1,99,1,1}, {"卤肉 ","初级★",1,80,0,0,0,0,0,30,1,0,0,99,1,0}, {"小鸭脖","初级★",1,100,0,0,0,0,0,35,1,0,0,99,1,1}, {"小蓝瓶","初级★",1,0,50,0,0,0,0,20,1,0,0,99,1,1}, {"中蓝瓶","中级★★",1,0,100,0,0,0,0,40,2,0,0,99,1,1}, {"大蓝瓶","高级★★★",1,0,200,0,0,0,0,80,3,0,1,99,1,1}, {"金鳌 ","高级★★★",3,0,0,5,0,0,0,200,2,0,2,99,1,1}, {"野山椒","中级★★",3,0,0,2,0,0,0,80,2,0,1,99,1,1}, {"巨蜥肉","高级★★★",3,0,0,0,10,0,0,100,3,0,1,99,1,1}, {"龙血 ","神级★★★★★",3,300,100,2,2,2,0,600,5,0,1,99,0,0}, {"龙肉 ","神级★★★★★",3,0,0,10,20,10,0,800,5,0,1,99,0,0}, {"木剑 ","初级★",2,0,0,10,0,0,0,50,1,0,0,1,1,0}, {"木衣 ","初级★",2,0,0,0,10,0,0,50,1,0,0,1,1,0}, {"木鞋 ","初级★",2,0,0,0,0,10,0,50,1,0,0,1,1,0} };//物品定义处:物品名,品质,作用值,加血,加魔,加攻击,加防御,加速度,加幸运,价格,占用包裹,加暴击,拥有量,最大拥有,可买(1可买,0不可),可卖(1可)。 struct ct gct[8]={ {"叶龙岛","嘎嘎,欢迎踏入死亡之岛!",0,4,1}, {"炎龙沙漠","Welcome!炎龙岛群龙大喊!",4,4,3}, {"青龙仙宫","青龙仙宫,天下第一宫!",8,4,5}, {"恶龙洞穴","你来这里是要作死么?",12,4,10}, {"水晶宫","龙王在此。还不下跪?",16,4,15}, {"龙王殿","真正的龙王在这里。",20,4,19}, {"超级魔龙","你能来到这里算你命大,不过到此结束了!",24,4,30}, };//地图定义:地图名,简介;怪物起点,怪物数量,限制等级 struct gw ggw[200]={ {"灼热龙蛋","呜呜。。呜呜。离我远一点!",1,5,5,0,30,30,10,10,12,3,1,1,1,0}, {"一岁幼龙","你是谁啊?想干嘛?不要过来!嗷",2,10,2,15,100,100,30,30,12,8,1,0,1,0}, {"三岁幼龙","我的奶瓶!",3,13,18,3,200,200,50,50,20,12,1,0,0,0}, {"五岁幼龙","就是你抢走了我弟弟的奶瓶?",5,16,20,5,300,300,70,70,25,20,1,1,0,0},//4 {"小龙盖茨","听说你打败了我的弟弟!受死吧!",7,23,25,6,380,380,80,80,35,28,1,1,1,0}, {"小龙比尔","我叫比尔,比尔盖茨的比尔。",9,26,30,9,430,430,89,89,40,35,1,1,1,0}, {"小龙乔布","乔布斯??不不,我是乔布。",12,35,40,11,500,500,95,95,50,40,1,1,1,0}, {"变异怪龙","为什这么看我?我和其他龙不一样吗?",15,50,50,15,800,800,100,100,100,80,1,1,1,0},//8 {"青龙甲","我是甲!",17,60,60,17,700,700,110,110,80,80,1,0,0,0}, {"青龙乙","我是乙!",19,65,65,18,750,750,110,110,85,80,1,1,0,0}, {"青龙丙","我是丙!",20,70,65,19,800,800,110,110,95,90,1,1,1,0}, {"青龙丁","我当然是丁喽!",24,90,80,20,1000,1000,110,110,120,100,1,1,1,1},//12 {"恶龙A","我很善良!",25,75,75,22,850,850,120,120,100,100,1,1,0,0}, {"恶龙B","我本善良!",26,80,80,22,900,900,120,120,105,105,1,1,1,0}, {"恶龙C","我最善良!",27,90,90,23,1100,1100,130,130,150,150,1,1,1,0}, {"恶龙D","我就是恶龙了,想咋滴??",30,100,100,25,1500,1500,140,140,300,150,1,1,1,1},//16 {"东海龙网","我是龙王!",31,105,105,26,1150,1150,130,130,200,160,1,1,1,0}, {"西海龙网","我是龙王!",32,110,110,27,1200,1200,130,130,210,180,1,1,1,0}, {"南海龙网","我是龙王!",33,115,115,28,1290,1290,135,135,230,200,1,0,0,0}, {"北海龙网","我是龙王!",35,160,180,30,1800,1800,150,150,600,300,1,1,1,1},//20 {"东海龙王","我不是龙网!",36,120,120,30,1300,1300,140,140,300,250,1,0,0,0}, {"西海龙王","我不是龙网!",37,125,125,32,1400,1400,150,150,350,300,1,0,1,0}, {"南海龙王","我不是龙网!",39,140,140,33,1600,1600,170,170,420,350,1,1,1,0}, {"北海龙王","我不是龙网!",45,200,200,36,2500,2500,200,200,1000,600,1,1,1,1},//24 {"魔龙守卫","啊,是人类啊,好久没吃到人类了!",46,150,150,34,1700,1700,180,180,450,400,1,0,0,0}, {"魔卫统领","我的手下被你干掉了??",47,160,160,35,1800,1800,190,190,500,500,1,1,1,0}, {"魔龙小弟","你找我大哥有什么事情啊?",48,180,180,36,2000,2000,200,200,550,550,1,1,1,1}, {"超级魔龙","呜呜。。呜呜。离我远一点!你这混蛋!",50,500,500,50,5000,5000,300,300,3000,2000,1,1,1,1},//28 };//怪物定义:名称,交流,等级,攻击,防御,速度,血,最大血,魔,最大魔,携带经验,携带金币,随机奖励药品(1有),随机武器,随机奇宝,允许逃跑(1不允许) struct skill gskill[100]={ {"治疗术 ","治疗术是一位善良的龙岛少女发明的,她用来治疗那些被屠龙勇士杀死父母后遗弃的小龙,后来她和一位屠龙勇士相爱,教会了这个勇士。补充HP50.",1,50,0,0,0,0,5,1,1}, {"磨光利刃","把你的刀磨得更加锋利,有效提升攻击力!“切龙皮就像切豆腐!”屠龙英雄盖尔这样说.小幅度提升攻击力",1,0,2,0,0,0,10,3,1}, {"猎龙斩 ","猎龙斩是一个猎人发明的,但他没有杀过龙,他坚信这招可以屠龙!小幅度提升攻击力和防御力。",1,0,2,2,0,0,30,5,1}, {"上古战技","上古?听起来好厉害的样子! 没错,拥有上古战技,屠龙毫不费力!!大幅提升攻击力,小幅度提升防御力。",1,0,4,2,0,0,50,7,1}, {"绝地天道","高深的绝地天道就像绝地武士的激光剑一样给龙致命一击!造成巨大伤害!大幅度提升攻击力,小幅度提升防御力。",1,0,5,3,0,0,100,10,1}, {"引雷入体","想想吧,天雷环绕你的身体和剑,大幅度提升攻击力和防御力!持续一个回合!均衡的提升攻击力和防御力。",2,0,4,3,0,0,120,15,1}, {"天龙死音","天龙临死的绝唱,被杀死他的勇士用诺基亚自带的录音机录下,威力无比强大!补充200HP,并短暂提升攻击力和防御力!",1,200,6,2,2,0,150,17,1}, {"人剑合一","人剑合一是剑士的最终奥义,剑是人,人亦剑,达到融会贯通的最高境界!强力提升攻击力!",1,0,8,0,0,0,180,20,1}, {"一战屠龙","绝对逆天战技!可造成对方大量损失,并对己方攻击力、防御力10倍提升一回合!并且强力补充HP5000!",1,5000,10,10,0,0,250,30,1}, };//技能定义 :名称,介绍,持续回合,加血,加攻击(百分比),加防御,加速度,加幸运,释放需要MP,限制等级,,允许释放(1允许), int main(void) //开始主菜单SS { cls; char ch; int pn; if(main_pd==1) { main_dh(); main_pd=0;} system("color 30"); for(pn=0;pn<60;pn++) printf("*"); printf("\n\n\n"); for(pn=0;pn<25;pn++) printf(" "); printf("【灭龙传说】\n\n"); for(pn=0;pn<15;pn++) printf(" "); printf("[A]--新的征程\n"); for(pn=0;pn<15;pn++) printf(" "); printf("[B]--旧的回忆\n"); for(pn=0;pn<15;pn++) printf(" "); printf("[C]--隐居山林\n"); printf("\n\n\n") ; for(pn=0;pn<60;pn++) printf("*"); while(1) { ch=getch(); if(ch=='a'||ch=='A') { newgame();} if(ch=='b'||ch=='B') {test(); main();} if(ch=='c'||ch=='C') end_from_menu(); if(ch=='w') god_here(); } } 【因论坛限制,本代码不完全,请下载附件】
下载:
mielong2014042003.rar
(10.89 KB)
示例程序:
mielong2014042003.rar
(26.29 KB)
[ 本帖最后由 winkill 于 2014-4-27 11:15 编辑 ]