下载源代码:Type=note
源代码:
# include ' con
#include 'image.h '
“# include”;
Int main()
{
GAMESTART();
return 0;
}
///////image.h/////////
#ifndef IMAGE_H_INCLUDED
#define IMAGE_H_INCLUDED
void startimage();//欢迎屏幕
string new name();//播放器名称
Void selectmap(字串名称);//选择地图
Void map1(字串名称);//土门旅馆地图
void drug map();//药店
void weapon map();//武器点
void hun back();//魂天桥背景
void w back();//武林同盟的背景
void boss back(string na);//陈毅绝对背景介绍
void fight select();//战斗选择
void showskill();//技术演示
void game over();//游戏结束了战败
void exitimage();//游戏结束
#endif //IMAGE_H_INCLUDED
///////image.cpp//////
# include ' con
#include 'image.h '
//启动接口
Void startimage()
{
MoveCursor (32,5);
Cout“丝绸刀岭大作战”;
MoveCursor (35,7):
Cout'[1]新的开始';
MoveCursor (35,9);
Cout'[2]旧回忆';
MoveCursor (35,11);
Cout'[3]离开游戏';
}
字串newname()
{
字串名称;
系统(' cls ');
MoveCursor (32,3);
Cout“丝绸刀岭大作战”;
MoveCursor (28,9);
Cout大侠请输入名字:’;
Cinname
Return name
}
Void selectmap(字串名称)
{
//string name=' test ';
系统(' cls ');
MoveCursor (32,3);
Cout“丝绸刀岭大作战”;
MoveCursor (35,4):
Cout '洪门弟子:' name
MoveCursor (15,7):
《cout》[1]土门客栈[2]修炼曲[3]boss[4]浙江进度挑战》;
}
Void map1(字串名称)
{
系统(' cls ');
MoveCursor (32,3);
Cout“丝绸刀岭大作战”;
MoveCursor (35,4):
Cout '洪门弟子:' name
MoveCursor (30,7):
Cout'[1]查看状态[2]百草枯';
MoveCursor (30,9);
Cout'[3]返回铁匠店[0]前一页';
}
//注意事项-1
Void drugmap()
{
系统(' cls ');
MoveCursor (32,3);
欢迎来到“大衣”百草枯。
MoveCursor (32,5);
Cout '我可以问战士需要什么吗?',即可从workspace页面中移除物件。
MoveCursor (30,7):
Cout'[1]炸鸡恢复300HP 300韩元';
MoveCursor (30,8):
Cout'[2]烤鸭500HP恢复500元';
MoveCursor (30,9);
Cout'[3]恢复鼠标水果50MP 100韩元';
MoveCursor (30,10);
Cout'[4]恢复灵芝100MP 200元';
MoveCursor (30,
12); cout<<"[0] 返回上一级"; } //注意不用-1 void weaponmap() { system("cls"); moveCursor (32,3); cout<<"欢迎来到铁匠铺"; moveCursor (32,5); cout<<"请问大侠有什么需要的?"; moveCursor (30,7); cout<<"[1] 卓越洪门剑 100攻击力 1000元"; moveCursor (30,8); cout<<"[2] 卓越千魂剑 200攻击力 2000元"; moveCursor (30,9); cout<<"[3] 卓越妖魔剑 300攻击力 3000元"; moveCursor (30,10); cout<<"[4] 极限万魂剑 400攻击力 4000元"; moveCursor (30,12); cout<<"[0] 返回上一级"; } void hunback() { system("cls"); moveCursor (10,5); cout<<"大侠,大侠快救我,浑天教来了!!!"; moveCursor (10,7); cout<<"小姐莫慌张,请慢慢道来.话说,这浑天教是??"; moveCursor (10,9); cout<<"大侠是外地人吧,您有所不知,浑天教那些2b小青年是最近一段时间出现在"; moveCursor (10,10); cout<<"土门客栈附近的小混混,经常抢路人的银鳞胸甲,调戏小姑娘."; moveCursor (10,11); cout<<"大侠可要帮我们做主啊!!"; moveCursor (10,13); cout<<"岂有此理,光天化日,朗朗乾坤,竟有此种2b青年在土门客栈附近撒野."; moveCursor (10,14); cout<<"姑娘莫怕,待我收拾了那帮混混就去你家找你!!"; moveCursor (10,16); cout<<"大侠请当心!"; moveCursor (45,18); system("pause"); } void wuback() { system("cls"); moveCursor (10,3); cout<<"前面那个!!给我站住!!"; moveCursor (10,5); cout<<"嗯?你们是.....??"; moveCursor (10,7); cout<<"我们是行侠仗义专门捕杀浑天教徒小混混的武林盟"; moveCursor (10,8); cout<<"听说你最近在打附近的浑天教徒?都已经砍到10级了啊!"; moveCursor (10,10); cout<<"哦,你们好.是呀,浑天教烧杀掳掠无恶不作,我实在看不下去."; moveCursor (10,12); cout<<"哎呦喂,说的和真的似的.小子,实话告诉你,你抢了我们的生意."; moveCursor (10,13); cout<<"我们武林盟自古以捕杀浑天教,收取村民供养为生"; moveCursor (10,14); cout<<"最近因为你的出现村民都不来交贡品了,我劝你少管闲事,否则..."; moveCursor (10,16); cout<<"否则怎样?我今天还就把这闲事管到底了!你们和那些败类有什么区别?!"; moveCursor (10,17); cout<<"多说无益,拔剑吧!....呀啊,看招!!"; moveCursor (10,19); cout<<"哼,敬酒不吃,兄弟们上!!"; moveCursor (47,21); system("pause"); } void bossback(string na) { system("cls"); moveCursor (10,5); cout<<na<<",你来了啊,没想到你能活到现在啊!"; moveCursor (10,7); cout<<"哼,秦义绝,我今天就是来找你报仇的,我会让你后悔当年没杀死我!!"; moveCursor (10,9); cout<<"呵呵,当年洪玄公那个傻老头为了能让你这个乖徒儿活下去"; moveCursor (10,10); cout<<"竟然跪下来求我.哈哈哈,大名鼎鼎的力王,竟然为了一个废物来求我"; moveCursor (10,11); cout<<"简直是笑话!我本想放你一条生路,你竟然自己过来送死."; moveCursor (10,13); cout<<"秦义绝,少说废话,今天我就要为师傅们报仇雪恨!!!"; moveCursor (10,14); cout<<"拿命来!!!!"; moveCursor (45,17); system("pause"); } void fightselect() { moveCursor (0,18); cout<<"[1]攻击 [2]技能 [3]防御 [4]包裹"<<endl; } void showskill() { moveCursor (0,18); cout<<"等等啊先别打,让我想想扔哪个技能! "<<endl; cout<<"[1]天罡战气 攻击力增加20点,持续两回合 消耗40MP"<<endl; cout<<"[2]绝对防御 抵挡下一次攻击,持续两回合 消耗60MP"<<endl; cout<<"[0]返回"<<endl; } void gameover() { system("cls"); moveCursor (32,7); cout<<"胜败乃兵家常事,大侠请重新来过!!!!!"; moveCursor (40,9); system("pause"); exit(0); } //退出界面 void exitimage() { system("cls"); cout<<" ▅▅▅▅▅▅▅ ▅▅▅▅▅ ▅ "<<endl; cout<<" ▅▅█▅▅ █ ▅ █ █ "<<endl; cout<<" █▅█▅█ █ █ █ █ "<<endl; cout<<" ▅█▅█▅█▅ ◢◤▋ ▅ ▼"<<endl; cout<<" █ ▅█ ██◤ ███ ●"<<endl; } #ifndef FUNCTION_H_INCLUDED #define FUNCTION_H_INCLUDED void gamestart();//游戏总控制整合 #endif // FUNCTION_H_INCLUDED #include "con; #include "image.h" #include "; void gamestart() { //PlaySound("my ;, NULL,SND_FILENAME | SND_PURGE | SND_NODEFAULT | SND_ASYNC | SND_LOOP); //初始化 char selectnum;//一级控制 char selectnum2;//二级控制 char selectnum3;//三级控制 int skillresult=3; int drugresult=3; int flaghuntian=0; int flagwulin=0; int flagboss=0; int deathflag1=0; int deathflag2=0; int level=0; int money=0; int exp=0; string name; character* cha=0; setCursorVisible (0); // setWindowTitle ("屌 丝 剑 灵 大 作 战-XiaoT"); //游戏开始 while(1) { startimage(); selectnum=getch(); if(selectnum=='1'||selectnum=='2'||selectnum=='3') break; } //读档 if(selectnum=='2') { cha=new character; cha->readdata(); name=cha->getname(); goto A; } //退出 if(selectnum=='3') exitimage(); //游戏开始 if(selectnum=='1') { name=newname(); cha=new character(name); A: while(1) { selectmap(name); selectnum=getch(); switch(selectnum) { //土门客栈场景 case '1': { while(1) { map1(name); selectnum2=getch(); //[1]查看状态 if(selectnum2=='1') { system("cls"); while(1) { cha->showall(); cha->showdrug(); selectnum3=getch(); if(selectnum3=='0') break; if(selectnum3>='1'&&selectnum3<='4') { cha->usedrug(selectnum3-49); system("cls"); } } continue; } //[2]百草堂 买药 if(selectnum2=='2') { while(1) { drugmap(); cha->showmoney(); selectnum3=getch(); if(selectnum3>='1'&&selectnum3<='4') cha->buydrug(selectnum3-49); if(selectnum3=='0') break; } } //[3]铁匠铺 买武器 if(selectnum2=='3') { while(1) { weaponmap(); cha->showmoney(); selectnum3=getch(); if(selectnum3>='1'&&selectnum3<='4') cha->buyweapon(selectnum3-48); if(selectnum3=='0') break; } } if(selectnum2=='0') break; } selectnum2=0; selectnum3=0; continue; } //小怪 case '2': { level=cha->getrank(); if(level<10) { if(flaghuntian==0) { flaghuntian++; hunback(); } system("cls"); huntian* hun=new huntian(); exp=hun->getexp(); money=hun->getmoney(); while(1) { //战斗界面 hun->showall(); cha->showall(); cout<<endl; fightselect(); selectnum2=getch(); //[1]普通攻击 if(selectnum2=='1') { cha->kill(*hun); deathflag1=cha->ifdeath(); deathflag2=hun->ifdeath(); //玩家死亡 if(deathflag1==1) gameover(); //怪物死亡 if(deathflag2==1) { deathflag2=0; cha->rankup(exp,money); cha->reskill(); break; } } //[2]技能 if(selectnum2=='2') { showskill(); while(1) { selectnum3=getch(); if(selectnum3=='1'||selectnum3=='2') { skillresult=cha->useskill(selectnum3-49); if(skillresult==1) cha->skillkill(*hun,selectnum3-49); break; } if(selectnum3=='0') break; } } //[3]防御 if(selectnum2=='3') { cha->defence(); } //[4]包裹 if(selectnum2=='4') { cha->showpack(); while(1) { selectnum3=getch(); if(selectnum3>='1'||selectnum3<='4') { drugresult=cha->usedrug(selectnum3-49); if(drugresult==1) cha->drugkill(*hun); break; } if(selectnum3=='0') break; } } } } if(level>=10) { if(flagwulin==0) { flagwulin++; wuback(); } system("cls"); wulin* wu=new wulin(); exp=wu->getexp(); money=wu->getmoney(); while(1) { //战斗界面 wu->showall(); cha->showall(); cout<<endl; fightselect(); selectnum2=getch(); //[1]普通攻击 if(selectnum2=='1') { cha->kill(*wu); deathflag1=cha->ifdeath(); deathflag2=wu->ifdeath(); //玩家死亡 if(deathflag1==1) gameover(); //怪物死亡 if(deathflag2==1) { deathflag2=0; cha->rankup(exp,money); cha->reskill(); break; } } //[2]技能 if(selectnum2=='2') { showskill(); while(1) { selectnum3=getch(); if(selectnum3=='1'||selectnum3=='2') { skillresult=cha->useskill(selectnum3-49); if(skillresult==1) cha->skillkill(*wu,selectnum3-49); break; } if(selectnum3=='0') break; } } //[3]防御 if(selectnum2=='3') { cha->defence(); } //[4]包裹 if(selectnum2=='4') { cha->showpack(); while(1) { selectnum3=getch(); if(selectnum3>='1'||selectnum3<='4') { drugresult=cha->usedrug(selectnum3-49); if(drugresult==1) cha->drugkill(*wu); break; } if(selectnum3=='0') break; } } } } continue; } //boss case '3': { if(flagboss==0) { flagboss++; bossback(name); } system("cls"); boss* qin=new boss(); exp=qin->getexp(); money=qin->getmoney(); while(1) { //战斗界面 qin->showall(); cha->showall(); cout<<endl; fightselect(); selectnum2=getch(); //[1]普通攻击 if(selectnum2=='1') { cha->kill(*qin); deathflag1=cha->ifdeath(); deathflag2=qin->ifdeath(); //玩家死亡 if(deathflag1==1) gameover(); //怪物死亡 if(deathflag2==1) { deathflag2=0; cha->rankup(exp,money); cha->reskill(); break; } } //[2]技能 if(selectnum2=='2') { showskill(); while(1) { selectnum3=getch(); if(selectnum3=='1'||selectnum3=='2') { skillresult=cha->useskill(selectnum3-49); if(skillresult==1) cha->skillkill(*qin,selectnum3-49); break; } if(selectnum3=='0') break; } } //[3]防御 if(selectnum2=='3') { cha->defence(); } //[4]包裹 if(selectnum2=='4') { cha->showpack(); while(1) { selectnum3=getch(); if(selectnum3>='1'||selectnum3<='4') { drugresult=cha->usedrug(selectnum3-49); if(drugresult==1) cha->drugkill(*qin); break; } if(selectnum3=='0') break; } } } continue; } //存档 case '4': { cha->savedata(); system("pause"); continue; } } } } } #include<iostream> #include <windows.h> #include <mm; //#pragma comment(lib, "winmm.lib") #include <conio.h> #include <iomanip> #include <fstream> #include <ctime> #ifndef CONTROL_H_INCLUDED #define CONTROL_H_INCLUDED using namespace std; //功能函数 int getMaxSize (); void moveCursor (int, int);//移动光标 void setWindowTitle (char*);//设置标题 void setCursorVisible (int );//光标隐藏 class huntian; //人物类 class character { //人物属性 protected: string name; int rank; int hpmax; int hpnow; int mpmax; int mpnow; int expmax; int expnow; int money; int atk; string weaponname[5]; int weapon[5]; int weaponhold;//持有哪个武器 int weaponprice[5]; int drugnum[4]; int drugprice[4]; string drugname[4]; string drugint[4];//药品介绍 int drugaffect[4]; string skillname[2]; int skillspend[2]; int skillstate[2]; int skilllast;//技能持续两回合 string skillint[2];//技能介绍 public: character (); character(string na);//构造函数初始化 //展示一些值 void showall(); void showmoney(); void showpack(); void showdrug(); //获取一些值 int getrank(); int getexp(); int getmoney(); string getname(); //功能函数 void buydrug(int num); void buyweapon(int num); void savedata(); int readdata(); void atkup();//提升攻击力 int ifdeath();//判断死亡 void rankup(int exp,int mon);//升级 int useskill(int sel);//使用技能 void reskill();//重置技能 int usedrug(int sel);//吃药 void defence();//防御 //友元 void kill(huntian &t);//攻击函数 void skillkill(huntian &t,int key);//使用技能回合设定 void drugkill(huntian &t);//吃药回合设定 }; //怪物 //浑天教徒 class huntian : public character { public: huntian(); void showall(); friend void character::kill(huntian &t); friend void character::skillkill(huntian &t,int key); friend void character::drugkill(huntian &t); }; //武林盟 class wulin :public huntian { public: wulin(); }; //boss class boss :public huntian { public: boss(); void showall(); }; #endif // CONTROL_H_INCLUDED #include "con; //新建人物及其初始化 character::character(){} character::character(string na) { name=na; rank=1; hpnow=hpmax=500; mpmax=mpnow=100; expmax=100; expnow=0; money=450; weaponname[0]="洪门断剑"; weaponname[1]="卓越洪门剑"; weaponname[2]="卓越千魂剑"; weaponname[3]="卓越妖魔剑"; weaponname[4]="极限万魂剑"; weaponprice[1]=1000; weaponprice[2]=2000; weaponprice[3]=3000; weaponprice[4]=4000; weapon[0]=50; for(int i=1;i<5;i++) { weapon[i]=i*100; } weaponhold=0; atk=10+weapon[weaponhold]+(rank-1)*2; //初始化药品数量 for(int i=0;i<4;i++) { drugnum[i]=0; } drugname[0]="炸鸡"; drugname[1]="烤鸭"; drugname[2]="鼠儿果"; drugname[3]="灵芝"; drugint[0]="恢复300HP"; drugint[1]="恢复500HP"; drugint[2]="恢复50MP"; drugint[3]="恢复100MP"; drugprice[0]=300; drugprice[1]=500; drugprice[2]=100; drugprice[3]=200; drugaffect[0]=300; drugaffect[1]=500; drugaffect[2]=50; drugaffect[3]=100; skillname[0]="天罡战气"; skillname[1]="绝对防御"; skillspend[0]=40; skillspend[1]=60; skillstate[0]=0; skillstate[1]=0; skilllast=2; skillint[0]="攻击力增加20点,持续两回合"; skillint[1]="抵挡下一次攻击,持续两回合"; } //显示人物状态 void character::showall() { cout<<"-----------------------------------------------------------------------"<<endl; cout<<"名称:"<<setw(10)<<name<<" "<<"等级:"<<setw(5)<<rank<<endl; cout<<"-----------------------------------------------------------------------"<<endl; cout<<"HP:"<<setw(6)<<hpnow<<"/"<<setw(6)<<hpmax<<" " <<" MP:"<<setw(6)<<mpnow<<"/"<<setw(6)<<mpmax<<endl; cout<<"-----------------------------------------------------------------------"<<endl; cout<<"攻击:"<<setw(6)<<atk<<" " <<"武器:"<<setw(10)<<weaponname[weaponhold]<<endl; cout<<"-----------------------------------------------------------------------"<<endl; cout<<"金币: "<<setw(6)<<money<<" " <<"经验:"<<setw(10)<<expnow<<"/"<<setw(10)<<expmax<<endl; cout<<"-----------------------------------------------------------------------"<<endl; } void character::showdrug() { for(int i=0;i<4;i++) { if(drugnum[i]!=0) cout<<"["<<i+1<<"]"<<" "<<drugname[i]<<" "<<drugnum[i]<<"个 "<<endl; } cout<<"[0] 返回"<<endl; cout<<"-----------------------------------------------------------------------"<<endl; } void character::buydrug(int num) { if(drugprice[num]<=money) { money-=drugprice[num]; drugnum[num]++; moveCursor (26,14); cout<<"你买到了1个"<<drugname[num]<<",花掉了"<<drugprice[num]<<"元"; Sleep(600); } else { moveCursor (26,14); cout<<"您的金币不够"; Sleep(600); } } void character::buyweapon(int num) { if (weaponprice[num]<=money&&num!=weaponhold) { money-=weaponprice[num]; weaponhold=num; moveCursor (26,14); cout<<"你已经装备了"<<weaponname[num]<<",花掉了"<<drugprice[num]<<"元"; atk=10+weapon[weaponhold]+(rank-1)*2; moveCursor (26,15); cout<<"当前攻击力为"<<atk; Sleep(850); } else if(weaponprice[num]<=money) { moveCursor (26,14); cout<<"你已经拥有该装备了,无需再次购买!"; Sleep(600); } else { moveCursor (26,14); cout<<"您的金币不够"; Sleep(600); } } //小值的取得 void character::showmoney() { moveCursor (0,0); cout<<"您有"<<money<<"元"; } int character::getrank() { return rank; } int character::getexp() { return expnow; } int character::getmoney() { return money; } string character::getname() { return name; } //技能与功能 void character::atkup() { atk+=20; } //死了返回1; 活着返回0; int character::ifdeath() { if(hpnow==0) return 1; else return 0; } //重置技能 void character::reskill() { for(int i=0;i<2;i++) skillstate[i]=0; } //升级 void character::rankup(int exp,int mon) { srand(time(0)); //打怪得奖励 if(exp!=0) { //10%得红药或者蓝药 if(rand()%10==0) { drugnum[0]++; cout<<"获得一个"<<drugname[0]<<endl; Sleep(800); } if(rand()%10==1) { drugnum[2]++; cout<<"获得一个"<<drugname[2]<<endl; Sleep(800); } //加属性 expnow+=exp; money+=mon; if(expnow>=expmax) { rank++; expnow-=expmax; expmax+=50; atk=10+weapon[weaponhold]+(rank-1)*3; hpmax+=rank*100*0.75; hpnow=hpmax; mpmax+=rank*20*0.55; mpnow=mpmax; cout<<"恭喜!你升级到了 "<<rank<<"级"<<endl; Sleep(1200); } } } void character::kill(huntian &t) { int tmpatk=0; int playerdamage; int def=0; int monsterdamage; //技能效果 if(skillstate[0]>0) { tmpatk=20; skillstate[0]--; } if(skillstate[1]>0) { def=t.atk; skillstate[1]--; } hpnow=; if(hpnow<=0) hpnow=0; t.hpnow=t.hpnow-atk-tmpatk; i;=0) t.hpnow=0; moveCursor (0,19); playerdamage=atk+tmpatk; tmpatk=0; cout<<"我凶残得一刀砍掉了 "<<playerdamage<<" 点血量"; moveCursor (0,20); monsterdamage=t.atk-def; def=0; cout<<"对手重重得咬了我一口 "<<monsterdamage<<" 点血量"<<endl; Sleep(1000); } void character::skillkill(huntian &t,int key) { int def=0; int monsterdamage; //技能效果 if(skillstate[0]>0&&key!=0) { skillstate[0]--; } if(skillstate[1]>0&&key!=1) { def=t.atk; skillstate[1]--; } hpnow=; if(hpnow<=0) hpnow=0; moveCursor (0,23); monsterdamage=t.atk-def; def=0; cout<<"对手重重得咬了我一口 "<<monsterdamage<<" 点血量"; Sleep(1100); } //1使用成功 0使用失败 int character::useskill(int sel) { if(sel==0||sel==1) { if(skillspend[sel]<=mpnow) { if(skillstate[sel]==0) { skillstate[sel]=skilllast; mpnow-=skillspend[sel]; cout<<"技能使用成功!"<<endl; Sleep(600); return 1; } else { cout<<"你这个技能的状态还在持续!"<<endl; Sleep(600); return 0; } } else { cout<<"你的魔力值不足!"<<endl; Sleep(600); return 0; } } return 2; } void character::defence() { //技能消耗一回合 if(skillstate[0]>0) { skillstate[0]--; } if(skillstate[1]>0) { skillstate[1]--; } cout<<"我对他放电,竟然抵挡住了一次攻击!!!!!"<<endl; Sleep(900); } void character::showpack() { moveCursor (0,18); for(int i=0;i<4;i++) { cout<<"["<<i+1<<"]"<<drugname[i]<<" "<<drugnum[i]<<"个 "<<drugint[i]<<" "<<endl; } cout<<"[0]返回"<<endl; } //1 成功 0失败 int character::usedrug(int sel) { //hp if(sel>=0&&sel<=2) { if(drugnum[sel]>0) { drugnum[sel]--; hpnow+=drugaffect[sel]; if(hpnow>hpmax) hpnow=hpmax; cout<<drugname[sel]<<"使用成功!"<<endl; Sleep(600); return 1; } else { cout<<"你没有这个物品!"<<endl; Sleep(600); return 0; } } //mp if(sel>=3&&sel<=4) { if(drugnum[sel]>0) { drugnum[sel]--; mpnow+=drugaffect[sel]; if(mpnow>mpmax) mpnow=mpmax; cout<<drugname[sel]<<"使用成功!"<<endl; Sleep(600); return 1; } else { cout<<"你没有这个物品!"<<endl; Sleep(600); return 0; } } return 2; } void character::drugkill(huntian &t) { int def=0; int monsterdamage; //技能消耗一回合 if(skillstate[0]>0) { skillstate[0]--; } if(skillstate[1]>0) { def=t.atk; skillstate[1]--; } hpnow=; if(hpnow<=0) hpnow=0; monsterdamage=t.atk-def; def=0; cout<<"对手重重得咬了我一口 "<<monsterdamage<<" 点血量"; Sleep(1100); } //怪物设定 huntian::huntian() { name="浑天教混混"; srand(time(0)); hpnow=rand()%260+245; mpnow=10; expnow=100; atk=rand()%30+30; money=450; } void huntian::showall() { system("cls"); cout<<"-----------------------------------------------------------------------"<<endl; cout<<"名称:"<<setw(10)<<name<<" "<<endl; cout<<"-----------------------------------------------------------------------"<<endl; cout<<"HP:"<<setw(6)<<hpnow<<" "<<" MP:"<<setw(6)<<mpnow<<endl; cout<<"-----------------------------------------------------------------------"<<endl; cout<<"攻击:"<<setw(6)<<atk<<" "<<endl; cout<<"-----------------------------------------------------------------------"<<endl; } wulin::wulin() { name="武林盟败类"; srand(time(0)); hpnow=rand()%100+695; mpnow=100; expnow=250; atk=rand()%140+70; money=750; } boss::boss() { name="秦 义 绝"; srand(time(0)); hpnow=rand()%2100+1950; mpnow=1000; expnow=1000; atk=rand()%315+300; money=1750; } void boss::showall() { system("cls"); cout<<"-----------------------------------------------------------------------"<<endl; cout<<"名称:"<<setw(10)<<name<<" " <<"小样,就你还敢挑战我秦义绝?? 赶紧乖乖受死吧~~~"<<endl; cout<<"-----------------------------------------------------------------------"<<endl; cout<<"HP:"<<setw(6)<<hpnow<<" "<<" MP:"<<setw(6)<<mpnow<<endl; cout<<"-----------------------------------------------------------------------"<<endl; cout<<"攻击:"<<setw(6)<<atk<<" "<<endl; cout<<"-----------------------------------------------------------------------"<<endl; } //存档 void character::savedata() { fstream saveout; (";,ios::out); saveout<<name<<" "<<rank<<" "<<hpnow<<" "<<hpmax<<" "<<mpnow<<" "<<mpmax<<endl; saveout<<atk<<endl; saveout<<expnow<<" "<<expmax<<" "<<money<<" "<<weaponhold<<endl; for(int i=0;i<4;i++) { saveout<<drugnum[i]<<" "<<drugname[i]<<" "<<drugprice[i] <<" "<<drugint[i]<<" "<<drugaffect[i]<<endl; } for(int i=0;i<5;i++) { saveout<<weapon[i]<<" "<<weaponname[i]<<" "<<weaponprice[i]<<endl; } for(int i=0;i<2;i++) { saveout<<skillname[i]<<" "<<skillspend[i]<<" " <<skillstate[i]<<" "<<skillint[i]<<endl; } saveout<<skilllast<<endl; (); system("cls"); moveCursor (28,7); cout<<"数据保存成功!"<<endl; } //读档 int character::readdata() { fstream savein; (";,ios::in); if(!savein) { system("cls"); moveCursor (28,7); cout<<"文件不存在,或打开失败!"<<endl; return 0; } savein>>name>>rank>>hpnow>>hpmax>>mpnow>>mpmax; savein>>atk; savein>>expnow>>expmax>>money>>weaponhold; for(int i=0;i<4;i++) { savein>>drugnum[i]>>drugname[i]>>drugprice[i] >>drugint[i]>>drugaffect[i]; } for(int i=0;i<5;i++) { savein>>weapon[i]>>weaponname[i]>>weaponprice[i]; } for(int i=0;i<2;i++) { savein>>skillname[i]>>skillspend[i]>>skillstate[i]>>skillint[i]; } savein>>skilllast; (); cout<<"数据读取成功!"<<endl; return 1; } //返回一行最大可以容纳的字符数 int getMaxSize () { HANDLE t_handle = GetStdHandle (STD_OUTPUT_HANDLE); CONSOLE_SCREEN_BUFFER_INFO t_info; GetConsoleScreenBufferInfo (t_handle, &t_info); return ; } //将输出符号定位到第[p_y]行第[p_x]个字符上。 void moveCursor (int p_x, int p_y) { int t_max = getMaxSize (); p_x = p_x < 1 ? 1 : (p_x >= t_max ? t_max - 1: p_x); p_y = p_y < 1 ? 1 : p_y; COORD t_pos; = p_x - 1; = p_y - 1; HANDLE t_handle = GetStdHandle (STD_OUTPUT_HANDLE); SetConsoleCursorPosition (t_handle, t_pos); } //设置光标是否可见,0为不可见,其它数字为可见 void setCursorVisible (int p_visitble) { HANDLE t_handle = GetStdHandle (STD_OUTPUT_HANDLE); CONSOLE_CURSOR_INFO t_info; GetConsoleCursorInfo (t_handle, &t_info); = p_visitble == FALSE ? FALSE : TRUE; SetConsoleCursorInfo (t_handle, &t_info); } //设置窗口标题,可以如下调用: setWindowTitle ("窗口标题"); void setWindowTitle (char* p_title) { SetConsoleTitle (p_title); }1.《【剑灵妖魔剑】剑灵文字游戏》援引自互联网,旨在传递更多网络信息知识,仅代表作者本人观点,与本网站无关,侵删请联系页脚下方联系方式。
2.《【剑灵妖魔剑】剑灵文字游戏》仅供读者参考,本网站未对该内容进行证实,对其原创性、真实性、完整性、及时性不作任何保证。
3.文章转载时请保留本站内容来源地址,https://www.lu-xu.com/gl/2582507.html