接着一繼續:由於有字數限制。因此要分開ios
==================c++
源文件windows
==================dom
- //main.cpp
- #include <iostream>
- #include <windows.h>
- #include<string>
- #include"wait.h"
- #include"character.h"
- #include "Enemy.h"
- #include"Blacksmith.h"
- #include"Select.h"
- using namespace std;
- int main()
- {
- void speek(char c1[][160]);
- system("TITLE 混沌");//NND。搜索了很久才知道怎樣設置。
- char c1[7][160]={"學c++至今也23天了,嗯,才學到第10章運算符重載,作這個遊戲的目的有幾個,主要呢是複習以前學所的內容,",
- "由於書上關於類的題目比較少嗯,還有就是今天是我生日,想作一個特別的禮物送給本身,",
- "讓本身明年的今天再看回這個遊戲必定會特別有趣.還要感謝貼吧的飛翔 雨夜,以及全部幫助過個人人,很是感謝.",
- "至於說爲啥分這麼多文件寫。。實際上是由於我看了第8章的公用接口與私有實現的分離0,因此練習下。這小東西",
- "- -花了我17個小時才竣工。。,昨天寫到2點用了4個小時,今天點9一直寫到晚上11點半了,真累啊.",
- "最後說下。。。雖然我知道。。這程序有不少不足。個人技術也不好。但爲了趕在今天內完成。質量可能不太好",
- "2011/3/14 混沌字。"};
- speek(c1);
- Select s1;
- s1.display();
- }
- void speek(char c1[][160])
- {
- int i,j,h=0;
- int s=50;
- for(i=0;i<7;i++)
- {
- system("CLS");
- cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
- cout<<"\t";
- for(j=0;c1[i][j]!='\0';j++)
- {
- cout<<c1[i][j];
- h++;
- Sleep(s);
- }
- Sleep(2000);
- }
- }
=================================ide
資源文件動畫
====================================spa
- //Blacksmith.cpp
- #ifndef ONE4
- #include <iostream>
- #include <windows.h>
- #include"wait.h"
- #include"Blacksmith.h"
- #include"Character.h"
- #include"Fighting.h"
- #include <time.h>
- using namespace std;
- void Blacksmith::display()
- {
- int a;
- do
- {system("CLS");
- cout<<endl<<endl<<endl<<endl<<endl<<endl;
- cout<<"\t\t\t〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓"<<endl;
- cout<<"\t\t\t☆ 黑死你鐵匠店 ★"<<endl;
- cout<<"\t\t\t〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓"<<endl;
- cout<<"\t\t\t1.強化武器(須要5點混沌幣)"<<endl;
- cout<<"\t\t\t2.特殊屬性附魔(須要5點混沌幣)"<<endl;
- cout<<"\t\t\t3.返回主界面"<<endl<<endl;
- cout<<"\t\t\t你目前的武器是:";
- cout<<Character::b_prefix_name<<Character::b_weapons_name<<"("<<(Character::b_weapons+Character::b_prefix)<<")";
- cout<<endl;
- cin>>a;
- cin.ignore(1024,'\n');
- if(a==1)//===========================武器強化==========================
- {
- if(Character::money<5)
- {
- do
- {
- cout<<"你的混沌幣不夠,請及時充值。";
- cin>>a;
- cin.ignore(1024,'\n');
- }while(a!=3);
- }
- else if(Character::money>=5)
- {
- Character::money-=5;
- if(Character::b_weapons_name=="木劍")
- {
- int b;
- b=Fighting::random(1);
- switch(b)
- {
- case 0:
- {
- Character::b_weapons_name=Character::weapons_name[1];//武器名更改
- Character::b_weapons=Character::weapons[1];//屬性更改
- Character::attack =(Character::b_attack+Character::b_weapons+Character::b_prefix);//最終***=基本+武器+前綴
- cout<<"強化成功!"<<endl;
- Sleep(1000);
- system("CLS");
- Wait::display(10);
- break;
- }
- default:cout<<"強化失敗。"<<endl;
- Sleep(1000);
- system("CLS");
- Wait::display(10);break;
- }
- }
- else if(Character::b_weapons_name=="木劍+1")
- { //================================================
- int b;
- b=Fighting::random(2);
- switch(b)
- {
- case 0:
- {
- Character::b_weapons_name=Character::weapons_name[2];//武器名更改
- Character::b_weapons=Character::weapons[2];//屬性更改
- Character::attack =(Character::b_attack+Character::b_weapons+Character::b_prefix);//最終***=基本+武器+前綴
- cout<<"強化成功!"<<endl;
- Sleep(1000);
- system("CLS");
- Wait::display(10);
- break;
- }
- default:cout<<"強化失敗。"<<endl;
- Sleep(1000);
- system("CLS");
- Wait::display(10);break;
- }
- }//=============================================
- else if(Character::b_weapons_name=="木劍+2")
- { //================================================
- int b;
- b=Fighting::random(5);
- switch(b)
- {
- case 0:
- {
- Character::b_weapons_name=Character::weapons_name[3];//武器名更改
- Character::b_weapons=Character::weapons[3];//屬性更改
- Character::attack =(Character::b_attack+Character::b_weapons+Character::b_prefix);//最終***=基本+武器+前綴
- cout<<"強化成功!"<<endl;
- Sleep(1000);
- system("CLS");
- Wait::display(10);
- break;
- }
- default:cout<<"強化失敗。"<<endl;
- Sleep(1000);
- system("CLS");
- Wait::display(10);break;
- }
- }//=============================================
- else if(Character::b_weapons_name=="木劍+3")
- { //================================================
- int b;
- b=Fighting::random(10);
- switch(b)
- {
- case 0:
- {
- Character::b_weapons_name=Character::weapons_name[4];//武器名更改
- Character::b_weapons=Character::weapons[4];//屬性更改
- Character::attack =(Character::b_attack+Character::b_weapons+Character::b_prefix);//最終***=基本+武器+前綴
- cout<<"強化成功!"<<endl;
- Sleep(1000);
- system("CLS");
- Wait::display(10);
- break;
- }
- default:cout<<"強化失敗。"<<endl;
- Sleep(1000);
- system("CLS");
- Wait::display(10);break;
- }
- }//=============================================
- else if(Character::b_weapons_name=="木劍+4")
- {
- cout<<"沒法強化,已是最高等級";
- Character::money+=5;
- }
- }
- }//===========================武器強化==========================
- else if(a==2)//===========================特殊附魔==========================
- {
- if(Character::money<5)
- {
- do
- {
- cout<<"你的混沌幣不夠,請及時充值。";
- cin>>a;
- cin.ignore(1024,'\n');
- }while(a!=3);
- }
- else if(Character::money>=5)
- {
- Character::money-=5;
- int b;
- b=Fighting::random(9);
- switch(b)
- {
- case 0:
- {
- Character::b_prefix_name=Character::prefix_name[1];//武器名更改
- Character::b_prefix=Character::prefix[1];//屬性更改
- Character::attack =(Character::b_attack+Character::b_weapons+Character::b_prefix);//最終***=基本+武器+前綴
- cout<<"附魔成功!"<<endl;
- Sleep(1000);
- system("CLS");
- Wait::display(10);
- break;
- }
- case 1:
- case 2:
- case 3:
- {
- Character::b_prefix_name=Character::prefix_name[2];//武器名更改
- Character::b_prefix=Character::prefix[2];//屬性更改
- Character::attack =(Character::b_attack+Character::b_weapons+Character::b_prefix);//最終***=基本+武器+前綴
- cout<<"附魔成功!"<<endl;
- Sleep(1000);
- system("CLS");
- Wait::display(10);
- break;
- }
- case 4:
- case 5:
- {
- Character::b_prefix_name=Character::prefix_name[3];//武器名更改
- Character::b_prefix=Character::prefix[3];//屬性更改
- Character::attack =(Character::b_attack+Character::b_weapons+Character::b_prefix);//最終***=基本+武器+前綴
- cout<<"附魔成功!"<<endl;
- Sleep(1000);
- system("CLS");
- Wait::display(10);
- break;
- }
- case 6:
- {
- Character::b_prefix_name=Character::prefix_name[4];//武器名更改
- Character::b_prefix=Character::prefix[4];//屬性更改
- Character::attack =(Character::b_attack+Character::b_weapons+Character::b_prefix);//最終***=基本+武器+前綴
- cout<<"附魔成功!"<<endl;
- Sleep(1000);
- system("CLS");
- Wait::display(10);
- break;
- }
- default:
- {
- Character::b_prefix_name=Character::prefix_name[0];//武器名更改
- Character::b_prefix=Character::prefix[0];//屬性更改
- Character::attack =(Character::b_attack+Character::b_weapons+Character::b_prefix);//最終***=基本+武器+前綴
- cout<<"附魔失敗。"<<endl;
- Sleep(1000);
- system("CLS");
- Wait::display(10);break;
- }
- }
- }
- }//===========================特殊附魔==========================
- }while(a!=3);
- system("CLS");
- }
- #define ONE4
- #endif ;
- //Character.cpp
- #include <iostream>
- #include <windows.h>
- #include<string>
- #include"Character.h"
- #include"Wait.h"
- using namespace std;
- /*=========常類=============*/
- int Character::money =10;
- string Character::name ="混沌";
- int Character::exp_max =100;
- int Character::exp_min =0;
- int Character::lv =1;
- //============庫類==============
- string Character::weapons_name[5] ={"木劍","木劍+1","木劍+2","木劍+3","木劍+4"};//武器名字
- int Character::weapons[5] ={10,15,25,60,120}; // 武器屬性
- string Character::clothes_name ="布衣";//衣服名字
- int Character::clothes =10;// 衣服屬性
- string Character::prefix_name[4] ={"","幸運的","巨熊的","破壞的"};// 屬性前綴名字
- int Character::prefix[4] ={0,5,30,60};// 屬性前綴
- /*=======身上裝備類==============*/
- string Character::b_weapons_name =weapons_name[0]; //身上武器名字
- int Character::b_weapons =weapons[0]; //身上武器屬性
- string Character::b_prefix_name =prefix_name[0]; //武器前綴名字
- int Character::b_prefix =prefix[0]; //武器前綴屬性
- string Character::b_clothes_name =clothes_name; //身上衣服名字
- int Character::b_clothes =clothes; //身上衣服屬性
- /*=========屬性類=============*/
- int Character::life_max =20;
- int Character::life_min =20;
- int Character::magic_max =10;
- int Character::magic_min =10;
- double Character::b_attack =5;//基本***
- double Character::attack =(b_attack+b_weapons+b_prefix);//最終***=基本+武器+前綴
- double Character::b_defense =10;//基本防護
- double Character::defense =(b_defense+b_clothes);
- void Character::display(string p)
- {
- if(p=="money")cout<<"混沌幣:"<<money<<"點";
- else if(p=="name")cout<<"『"<<name<<"』";
- else if(p=="exp")
- {
- while(exp_min>=exp_max)
- {
- int temp=0;
- temp=exp_min-exp_max;
- exp_max=exp_max*1.5*lv;//經驗公式
- exp_min=temp;
- lv++;
- //====升級屬性提高=====//
- life_max=life_max*1.5;//------升級後生命增長
- life_min=life_max;// ------生命全滿
- magic_max=magic_max*1.5;//同上
- magic_min=magic_max;// ----
- b_attack=b_attack*1.5;//***增長
- b_defense=b_defense*1.5;//防護增長
- }
- cout<<"Exp:"<<exp_min<<"/"<<exp_max;
- }
- else if(p=="lv")cout<<"Lv:"<<lv;
- else if(p=="life")
- {
- cout<<"Hp:";
- cout<<life_min<<"/"<<life_max<<" ";
- if(life_min > life_max*0.6&&life_min<=life_max*0.8)
- cout<<'\003'<<'\003'<<'\003'<<'\003';
- else if (life_min > life_max*0.4&&life_min<=life_max*0.6)
- cout<<'\003'<<'\003'<<'\003';
- else if (life_min > life_max*0.2&&life_min<=life_max*0.4)
- cout<<'\003'<<'\003';
- else if (life_min>0&&life_min<=life_max*0.2)
- cout<<'\003';
- else if (life_min==0)
- cout<<"死亡";
- else
- cout<<'\003'<<'\003'<<'\003'<<'\003'<<'\003';
- }
- else if (p=="magic")//因爲沒開發技能。。因此無論了
- {
- cout<<"Mp:"<<magic_min<<"/"<<magic_max<<" ";
- if(magic_min<=magic_max*0.8)
- cout<<'\016'<<'\016'<<'\016'<<'\016';
- else if (magic_min<=magic_max*0.6)
- cout<<'\016'<<'\016'<<'\016';
- else if (magic_min<=magic_max*0.4)
- cout<<'\016'<<'\016';
- else if (magic_min<=magic_max*0.2)
- cout<<'\016';
- else if (magic_min==0)
- cout<<" ";
- else
- cout<<'\016'<<'\016'<<'\016'<<'\016'<<'\016';
- }
- else if (p=="attack")cout<<"***力:"<<attack<<"("<<b_attack<<"+"<<(b_weapons+b_prefix)<<")";
- else if (p=="defense")cout<<"防護力:"<<defense<<"("<<b_defense<<"+"<<b_clothes<<")";
- else if (p=="w_name")cout<<"武器:"<<b_prefix_name<<b_weapons_name<<"("<<(b_weapons+b_prefix)<<")";
- else if (p=="c_name")cout<<"衣服:"<<b_clothes_name<<"("<<b_clothes<<")";
- }
- void Character::show()//人物頭像
- {
- cout<<" __------__ " <<endl
- <<" /~ ~\\ "<<endl
- <<" | //^\\//^\\ |" << endl
- <<" /~~\ || o| |o|:~\\ "<<endl
- <<"| |6 ||___|_|_|l: l "<<endl
- <<" \__. / o \\ /' "<<endl
- <<" | ( O ) "<<endl
- <<" `\\ \\ / "<<endl
- <<" ) ~------~`\\ "<<endl;
- }
- void Character::view_properties()//查看屬性
- {
- int a=0;
- do
- {
- system("CLS");
- cout<<endl;
- cout<<endl;
- cout<<endl;
- cout<<"\t\t\t\t ①返回選擇界面"<<endl;
- string life="life",magic="magic",money="money",attack="attack",defense="defense",
- name="name",w_name="w_name",c_name="c_name";
- //其實能夠直接打字符串的。。不過。。我怕忘記了。。因此。。
- show();
- cout<<endl;
- cout<<" ";
- display(name);
- cout<<"\t";
- display("lv");
- cout<<endl;
- display("exp");
- cout<<endl;
- display(life);
- cout<<"\t";
- display(attack);
- cout<<endl;
- display(magic);
- cout<<"\t";
- display(defense);
- cout<<endl;
- display(money);
- cout<<endl<<"=======裝備欄========"<<endl;
- display(w_name);
- cout<<endl;
- display(c_name);
- cout<<endl;
- cin>>a;
- cin.ignore(1024,'\n');
- if(a==1)
- {
- Wait::display(10);
- }
- }while(a!=1);
- }
- //Enemy.cpp
- #include <iostream>
- #include <windows.h>
- #include<string>
- #include"Character.h"
- #include"Enemy.h"
- using namespace std;
- string Enemy::e_name="夢魘雜兵";
- int Enemy::e_hp=10;
- int Enemy::e_att=10;
- int Enemy::e_def=10;
- //====BOSS=====
- string Enemy::boss_name="心魔";
- int Enemy::boss_hp=100;
- int Enemy::boss_att=100;
- int Enemy::boss_def=100;
- void Enemy::display(string p)
- {
- if(p=="e_name")cout<<"『"<<e_name<<"』";
- else if(p=="e_hp")cout<<"Hp:"<<e_hp;
- else if(p=="e_att")cout<<"***力:"<<e_att;
- else if(p=="boss_name")cout<<"¤"<<boss_name<<"¤";
- else if(p=="boss_hp")cout<<"Hp:"<<boss_hp;
- else if(p=="boss_att")cout<<"***力:"<<boss_att;
- }
- void Enemy::set(string p)
- {
- if(p=="e_name")//雜兵 屬性設置
- {
- e_hp=(Character::life_max)/2;//角色生命的一半
- e_att=(Character::attack)*1.5;//角色***的1.5
- e_def=5;//防護值
- }
- if(p=="boss_name")//BOSS 屬性設置
- {
- boss_hp=(Character::life_max)*3;//角色生命的3倍
- boss_att=(Character::attack)*2;//角色***的2倍
- boss_def=0;//防護值
- }
- }
- //Fighting.cpp
- #ifndef ONE5
- #include<iostream>
- #include<string>
- #include<windows.h>
- #include <time.h>
- #include"Fighting.h"
- #include"Enemy.h"
- #include"Character.h"
- #include"wait.h"
- using namespace std;
- char Fighting::role[3][50] ={":廢話少說,看招!\0", ":吃我一拳!", ":………………打不打啊,我要睡着了。。。"};//人物對話
- char Fighting::e_role[3][50] ={":今每天氣不錯~", ":大爺今天心情不錯,不殺你,快從我眼前消失", ":武功再高,也怕個人菜刀!" };//怪物對話
- char Fighting::b_role[3][50] ={":人類,你這是自尋死路!", ":很久沒見過玩具來這裏了~", ":想打敗我那是癡心妄想!我是無敵的!" };//BOSS對話
- string Fighting::mode="att";
- void Fighting::d_speed(int a,string p)//用法d_speed(rand(3),"role/e_role/b_role")
- {
- int i=0;
- int s=50;
- if(p=="role")
- while(role[a][i]!='\0')
- {
- cout<<role[a][i];
- Sleep(s);
- i++;
- }
- else if(p=="e_role")
- while(e_role[a][i]!='\0')
- {
- cout<<e_role[a][i];
- Sleep(s);
- i++;
- }
- else if (p=="b_role")
- while(b_role[a][i]!='\0')
- {
- cout<<b_role[a][i];
- Sleep(s);
- i++;
- }
- }
- int Fighting::random(int a)
- {
- srand((unsigned)time(NULL));
- return (rand()%a);
- }
- void Fighting::hurt(string p1)//p1打人者 mod爲戰鬥模式att or def
- {
- if(p1=="e_name")//雜兵打主角
- {
- double a=0;//被打防減傷率
- if(mode=="def")//若是角色是防護模式
- {
- double m=Character::defense*2;//防護值加倍
- a=1-1/(1+m/10);//防護值物免傷率=1-1/(1+防守者防護總值/10)
- cout<<"\t\t\t\t\t";
- Character::display("name");
- cout<<"防護"<<endl;
- }
- else if(mode=="att")
- {
- a=1-1/(1+Character::defense/10);//防護值物免傷率=1-1/(1+防守者防護總值/10)
- }
- //=====傷害賦值=======
- double b=0;
- b=Enemy::e_att-Enemy::e_att*a;//傷害=***-****免傷
- Character::life_min=Character::life_min-int(b);
- cout<<"\t\t\t\t\t";
- Character::display("name");
- cout<<"受到了"<<int(b)<<"點傷害"<<endl;
- }
- else if(p1=="boss_name")//boss打主角
- {
- double a=0;//被打防減傷率
- if(mode=="def")//若是角色是防護模式
- {
- double m=Character::defense*2;//防護值加倍
- a=1-1/(1+m/10);//防護值物免傷率=1-1/(1+防守者防護總值/10)
- }
- else if(mode=="att")
- {
- a=1-1/(1+Character::defense/10);//防護值物免傷率=1-1/(1+防守者防護總值/10)
- }
- //=====傷害賦值=======
- double b=0;
- b=Enemy::boss_att-Enemy::boss_att*a;//傷害=***-****免傷
- Character::life_min=Character::life_min-int(b);
- cout<<"\t\t\t\t\t";
- Character::display("name");
- cout<<"受到了"<<int(b)<<"點傷害"<<endl;
- }
- else if(p1=="name_e")//主角打雜兵
- {
- double a=0;//被打防減傷率
- a=1-1/(1+Enemy::e_def/10);//防護值物免傷率=1-1/(1+防守者防護總值/10)
- //=====傷害賦值=======
- double b=0;
- b=Character::attack-Character::attack*a;//傷害=***-****免傷
- Enemy::e_hp=Enemy::e_hp-int(b);
- cout<<"\t\t\t\t\t";
- Enemy::display("e_name");
- cout<<"受到了"<<int(b)<<"點傷害"<<endl;
- }
- else if(p1=="name_boss")//主角打BOSS
- {
- double a=0;//被打防減傷率 BOSS無防護
- // a=1-1/(1+Enemy::e_def/10);//防護值物免傷率=1-1/(1+防守者防護總值/10)
- //=====傷害賦值=======
- double b=0;
- b=Character::attack-Character::attack*a;//傷害=***-****免傷
- Enemy::boss_hp=Enemy::boss_hp-int(b);
- cout<<"\t\t\t\t\t";
- Enemy::display("boss_name");
- cout<<"受到了"<<int(b)<<"點傷害"<<endl;
- }
- }
- void Fighting::display(string p)
- {
- if(p=="e_name")
- {
- system("CLS");//清屏
- cout<<endl;
- cout<<endl;
- cout<<endl;
- Enemy::set(p);//設置敵人屬性
- string e_name="e_name",e_hp="e_hp",e_att="e_att";
- cout<<" ";
- Enemy::display(e_name);
- d_speed(random(2),"e_role");//敵方對話
- cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
- cout<<" ";
- Sleep(1000);
- Character::display("name");
- d_speed(random(2),"role");//我方對話
- Sleep(1000);//等待1秒
- system("CLS");//清除對話
- Wait::display(13);//轉場動畫
- //=============================
- //=========戰鬥開始============
- //=============================
- //===========界面數據輸出========
- do
- {
- system("CLS");
- cout<<endl<<"\t\t 1.***"<<endl<<"\t\t 2.防護"<<endl<<endl<<endl;
- cout<<"\t\t\t\t\t\t";
- Enemy::display(e_name);
- cout<<endl;
- cout<<"\t\t\t\t\t\t";
- Enemy::display(e_hp);
- cout<<"\t";
- Enemy::display(e_att);
- cout<<endl<<endl<<endl<<endl;
- Character::show();//====頭像
- cout<<"\t";
- Character::display("name");
- cout<<" ";
- Character::display("lv");
- cout<<endl<<" ";
- Character::display("life");
- cout<<" ";
- Character::display("attack");
- cout<<endl<<" ";
- Character::display("magic");
- cout<<" ";
- Character::display("defense");
- cout<<endl;
- //===========界面數據輸出========
- //============選擇戰鬥方式========//
- int a;
- cin>>a;
- cin.ignore(1024,'\n');
- if(a==1)
- {
- mode="att";//***模式
- hurt("name_e");//角色打怪
- if(Enemy::e_hp>0)//怪未死
- {
- Sleep(2000);
- hurt("e_name");//打角色
- if(Character::life_min<0)//角色死了
- {
- Sleep(2000);
- Wait::display(10);
- Sleep(2000);
- cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
- cout<<"\t\t\t\t角色死亡 GAME OVER"<<endl;
- Sleep(4000);
- cout<<"\t\t\t\t哈被騙了吧,菜鳥,復活術~";
- }
- }
- else if(Enemy::e_hp<0)//怪死了
- {
- Sleep(2000);
- Wait::display(10);
- cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
- int up;
- up=Character::lv;
- Character::money+=20;
- Character::exp_min+=20;
- cout<<"\t\t\t\t得到了20點混沌幣";
- cout<<endl;
- cout<<"\t\t\t\t得到了20點經驗值";
- cout<<endl;
- cout<<"\t\t\t\t";
- Character::display("exp");
- cout<<endl;
- if(up<Character::lv)
- cout<<"\t\t\t\t升級了!!!";
- Character::attack =(Character::b_attack+Character::b_weapons+Character::b_prefix);//最終***=基本+武器+前綴
- cout<<endl;
- Sleep(2000);
- Wait::display(10);
- }
- }
- else if(a==2)
- {
- mode="def";//防護模式
- hurt("e_name");//怪打角色
- Sleep(2000);
- if(Character::life_min<0)//角色死了
- {
- Sleep(2000);
- Wait::display(10);
- Sleep(2000);
- cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
- cout<<"\t\t\t\t角色死亡 GAME OVER"<<endl;
- Sleep(4000);
- cout<<"\t\t\t\t哈被騙了吧,菜鳥,復活術~";
- }
- else Sleep(2000);
- }
- }while((Enemy::e_hp>0)&&(Character::life_min>0));
- if(Character::life_min<=0)
- Character::life_min=Character::life_max;
- }
- //===============================================
- //==================BOSS==========================
- //===============================================
- else if(p=="boss_name")
- {
- system("CLS");//清屏
- cout<<endl;
- cout<<endl;
- cout<<endl;
- Enemy::set(p);//設置敵人屬性
- cout<<" ";
- Enemy::display("boss_name");
- d_speed(random(2),"b_role");//敵方對話
- cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
- cout<<" ";
- Sleep(1000);
- Character::display("name");
- d_speed(random(2),"role");//我方對話
- Sleep(1000);//等待1秒
- system("CLS");//清除對話
- Wait::display(13);//轉場動畫
- //=============================
- //=========戰鬥開始============
- //=============================
- //===========界面數據輸出========
- do
- {
- system("CLS");
- cout<<endl<<"\t\t 1.***"<<endl<<"\t\t 2.防護"<<endl<<endl;
- cout<<"\t\t\t\t\t\t";
- Enemy::display("boss_name");
- cout<<endl;
- cout<<"\t\t\t\t\t\t";
- Enemy::display("boss_hp");
- cout<<"\t";
- Enemy::display("boss_att");
- cout<<endl<<endl<<endl<<endl;
- Character::show();//====頭像
- cout<<"\t";
- Character::display("name");
- cout<<" ";
- Character::display("lv");
- cout<<endl<<" ";
- Character::display("life");
- cout<<" ";
- Character::display("attack");
- cout<<endl<<" ";
- Character::display("magic");
- cout<<" ";
- Character::display("defense");
- cout<<endl;
- //===========界面數據輸出========
- //============選擇戰鬥方式========//
- int a;
- cin>>a;
- cin.ignore(1024,'\n');
- if(a==1)
- {
- mode="att";//***模式
- hurt("name_boss");//角色打怪
- if(Enemy::boss_hp>0)//怪未死
- {
- Sleep(2000);
- hurt("boss_name");//打角色
- if(Character::life_min<0)//角色死了
- {
- Sleep(2000);
- Wait::display(10);
- Sleep(2000);
- cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
- cout<<"\t\t\t\t角色死亡 GAME OVER"<<endl;
- Sleep(4000);
- cout<<"\t\t\t\t哈被騙了吧,菜鳥,復活術~";
- }
- Sleep(2000);
- }
- else if(Enemy::boss_hp<0)//怪死了
- {
- Sleep(2000);
- Wait::display(10);
- cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
- int up;
- up=Character::lv;
- Character::money+=1000;
- Character::exp_min+=2000;
- cout<<"\t\t\t\t得到1000點混沌幣。";
- cout<<endl;
- cout<<"\t\t\t\t得到2000點經驗幣。";
- cout<<endl;
- cout<<"\t\t\t\t";
- Character::display("exp");
- cout<<endl;
- if(up<Character::lv)
- cout<<"\t\t\t\t升級了!!!";
- cout<<endl;
- Sleep(2000);;
- Wait::display(10);
- }
- }
- else if(a==2)
- {
- mode="def";//防護模式
- hurt("boss_name");//怪打角色
- Sleep(2000);
- if(Character::life_min<0)//角色死了
- {
- Sleep(2000);
- Wait::display(10);
- Sleep(2000);
- cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
- cout<<"\t\t\t\t角色死亡 GAME OVER"<<endl;
- Sleep(4000);
- cout<<"\t\t\t\t哈被騙了吧,菜鳥,復活術~";
- }
- else Sleep(2000);
- }
- }while((Enemy::boss_hp>0)&&(Character::life_min>0));
- if(Character::life_min<=0)
- Character::life_min=Character::life_max;
- }
- }
- #define ONE5
- #endif ;
- //Select.cpp
- #include<iostream>
- #include"Select.h"
- #include"Fighting.h"
- #include"Character.h"
- #include"Blacksmith.h"
- using namespace std;
- void Select::display()
- {
- int a;
- do
- {
- system("CLS");
- cout<<endl<<endl<<endl<<endl<<endl;
- cout<<"\t\t\t※①練級"<<endl;
- cout<<"\t\t\t※②查看屬性"<<endl;
- cout<<"\t\t\t※③鐵匠鋪"<<endl;
- cout<<"\t\t\t※④挑戰BOSS"<<endl;
- cout<<"\t\t\t※⑤退出遊戲"<<endl;
- cin>>a;
- cin.ignore(1024,'\n');
- if(a==1)
- {
- Fighting::display("e_name");
- }
- else if(a==2)
- {
- Character::view_properties();
- }
- else if(a==3)
- {
- Blacksmith::display();
- }
- else if(a==4)
- {
- Fighting::display("boss_name");
- }
- }while(a!=5);
- }
- //Wait.cpp
- #include <iostream>
- #include <windows.h>
- using namespace std;
- #include"wait.h"
- void Wait::display(int time)
- {
- int j;
- int k;
- for(j=0;j<time;j++)
- {
- cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
- for(k=0;k<=j;k++)
- cout<<" ";
- cout<<" oooO"<<endl;
- for(k=0;k<=j;k++)
- cout<<" ";
- cout<<" ( )"<<endl;
- for(k=0;k<=j;k++)
- cout<<" ";
- cout<<" \\ ( "<<endl;
- for(k=0;k<=j;k++)
- cout<<" ";
- cout<<" \\_)"<<endl;
- Sleep(100);
- system("CLS");
- }
- }
OK了。好睏啊接口