?? game.cpp
字號:
#include "iostream"
#include "Player.h"
#include "Map.h"
#include "Text.h"
#include "spell.h"
#include "item.h"
#include "color.h"
#include <windows.h>
using namespace std;
//對象的聲明
extern int a1,a2,a3,a4;
CFile cf;
map gamemap;
color col;
char *npcname(int lv);
int npchp(int lv);
int npcdam(int lv);
int npcdef(int lv);
int npcstr(int lv);
void juqing(char *s);
void f_input(char n);
void flash();
void fight();
void lvup();
void die();
void useitem();
void drawhp(int a,int b);
void getinput(char n);//按鍵處理
spell jn1("裂空斬",55,25),jn2("黑暗雷光",70,35);//初始化技能
item yao1("生命藥水","瞬間恢復500點HP",2),yao2("魔法藥水","瞬間恢復500點MP",2);//初始化藥品
bool zt=true;//戰斗和非戰斗狀態轉換
bool ys;
bool tj;
bool qh;
int dm; //一個用于增加傷害的隨機數
Hero hero;
int hero_x = 2;
int hero_y = 2;
Npc boss(120,70,28,"地域愛琴海");//初始化怪物對象
Npc npc1(45,35,22,"狂狼");
Npc npc2(74,52,25,"黑熊");
void main()
{
char c_in[5];
cout<<" "<<"游 戲 : 幻世梵天"<<endl<<endl;
juqing("夢幻般的梵天大陸,風云變幻的種族聯盟,當七夜走到命運注定的聯盟之后,他面對的將是誰?他的敵人會是誰?他是誰?他的力量再也無法挽回嗎?他將要做什么?他將會做什么?在各族會聚的聯盟中,一個人的力量將能改變什么?");
juqing("幻世梵天的最終部——梵天大陸,即將展現梵天的全部情景!");
Sleep(3000);
system("cls");
cout<<" "<<"游 戲 : 幻世梵天"<<endl<<endl;
cf.open();
cf.put();
Sleep(3000);
printf("\n");
gamemap.Initmap();
gamemap.move(hero_y,hero_x);
flash();
while(true)
{
flash();
cout<<"請輸入操作指令:";
cin>>c_in;
if(!zt)
{
fight();
}
else
{
getinput(c_in[0]);
}
lvup();
die();
}
printf("\n\n");
}
void getinput(char n)//普通狀態下的按鍵處理
{
srand(GetTickCount());
int num=rand()%10;
switch(n)
{
case 'c':
case 'C':
flash();
cout<<"=========================================="<<endl;
cout<<"英雄:"<<hero.getname()<<endl;
cout<<"等級:"<<hero.getlv()<<endl;
cout<<"力量:"<<hero.getStr()<<endl;
cout<<"敏捷:"<<hero.getDex()<<endl;
cout<<"智力:"<<hero.getInt()<<endl;
cout<<"攻擊:"<<hero.getdam()<<endl;
cout<<"防御:"<<hero.getdef()<<endl;
cout<<"HP:"<<hero.getHp()<<endl;
cout<<"MP:"<<hero.getMp()<<endl;
system("pause");
break;
case 'w':
case 'W':
hero_y--;
if (gamemap.mapMax[hero_y][hero_x] == 1)
{
hero_y++;
printf("撞樹上了!\n");
system("pause");
}
if (gamemap.mapMax[hero_y][hero_x] != 5)
{
if(num%3==0)
{
zt=false;
}
}
gamemap.Initmap();
if (hero_y<0)
{
hero_y=0;
gamemap.move(0,hero_x);
printf("墻都快被你推倒了,回頭吧!\n");
system("pause");
}
else
{
gamemap.move(hero_y,hero_x);
}
if ((hero_x == 3 && hero_y == 0) )
{
juqing("村長:“七夜,到樹林的那邊找到地域愛琴海他會交給你怎么做!~");
juqing("村長:“順便到藥師和鐵匠那里看看也許會獲得幫助");
system("pause");
}
if ((hero_x == 1 && hero_y == 0) )
{
if (!tj)
{
juqing("鐵匠:“你的爺爺被魔獸襲擊時他的劍遺失在了遠處的樹林中!”");
juqing("鐵匠:“找回那把帝王劍才能被地域愛琴海認可,回來時我還可以幫你強化它”");
system("pause");
}
else
{
if(!qh)
{
juqing("太好了,你終于找到帝王劍了,這下梵天大陸有救了,來我幫你強化了它。");
cout<<"得到 帝王劍(超)"<<endl;
qh=true;
system("pause");
}else
{
juqing("拿著這把劍去征服整個梵天大陸吧");
system("pause");
}
};
}
if ((hero_x == 0 && hero_y == 2) )
{
if (!ys)
{
juqing("藥師:“孩子,這幾瓶藥水帶上防身,打倒怪物得到的魔核我也可以給你制作藥水”");
cout<<"得到 生命藥水*2 魔法藥水*2"<<endl;
ys=true;
system("pause");
}else
{
juqing("藥師:“出了村子就會受到魔獸的襲擊。”");
}
}
if ((hero_x == 19 && hero_y == 1) )
{
if (!tj)
{
juqing("找到遺失的帝王劍。。。");
cout<<"得到 帝王劍"<<endl;
tj=true;
system("pause");
}else
{
juqing("這片地方已經搜索過了");
system("pause");
}
}
if ((hero_x == 15 && hero_y == 10) )
{
if (!qh)
{
juqing("地域愛琴海:“你連個真正的武器都沒有怎么來打仗,去找到真正的帝王劍再來找我完成試煉吧”");
system("pause");
}else
{
if(npcname(hero.getlv())!=boss.getname())
{
juqing("你太弱了,起碼練到5級以后再來找我吧");
system("pause");
}else
{
juqing("很不錯,你現在有資格來挑戰我了,讓我來看看你的試煉結果吧。");
system("pause");
zt=false;
}
}
}
break;
case 's':
case 'S':
hero_y++;
if (gamemap.mapMax[hero_y][hero_x] == 1)
{
hero_y--;
printf("撞樹上了!\n");
system("pause");
}
if (gamemap.mapMax[hero_y][hero_x] != 5)
{
if(num%3==0)
{
zt=false;
}
}
gamemap.Initmap();
if (hero_y>11)
{
hero_y = 11;
gamemap.move(11,hero_x);
printf("墻都快被你推倒了,回頭吧!\n");
system("pause");
}
else
{
gamemap.move(hero_y,hero_x);
}
if ((hero_x == 3 && hero_y == 0) )
{
juqing("村長:“七夜,到樹林的那邊找到地域愛琴海他會交給你怎么做!~");
juqing("村長:“順便到藥師和鐵匠那里看看也許會獲得幫助");
system("pause");
}
if ((hero_x == 1 && hero_y == 0) )
{
if (!tj)
{
juqing("鐵匠:“你的爺爺被魔獸襲擊時他的劍遺失在了遠處的樹林中!”");
juqing("鐵匠:“找回那把帝王劍才能被地域愛琴海認可,回來時我還可以幫你強化它”");
system("pause");
}
else
{
if(!qh)
{
juqing("太好了,你終于找到帝王劍了,這下梵天大陸有救了,來我幫你強化了它。");
cout<<"得到 帝王劍(超)"<<endl;
qh=true;
system("pause");
}else
{
juqing("拿著這把劍去征服整個梵天大陸吧");
system("pause");
}
};
}
if ((hero_x == 0 && hero_y == 2) )
{
if (!ys)
{
juqing("藥師:“孩子,這幾瓶藥水帶上防身,打倒怪物得到的魔核我也可以給你制作藥水”");
cout<<"得到 生命藥水*2 魔法藥水*2"<<endl;
ys=true;
system("pause");
}else
{
juqing("藥師:“出了村子就會受到魔獸的襲擊。”");
}
}
if ((hero_x == 19 && hero_y == 1) )
{
if (!tj)
{
juqing("找到遺失的帝王劍。。。");
cout<<"得到 帝王劍"<<endl;
tj=true;
system("pause");
}else
{
juqing("這片地方已經搜索過了");
system("pause");
}
}
if ((hero_x == 15 && hero_y == 10) )
{
if (!qh)
{
juqing("地域愛琴海:“你連個真正的武器都沒有怎么來打仗,去找到真正的帝王劍再來找我完成試煉吧”");
system("pause");
}else
{
if(npcname(hero.getlv())!=boss.getname())
{
juqing("你太弱了,起碼練到5級以后再來找我吧");
system("pause");
}else
{
juqing("很不錯,你現在有資格來挑戰我了,讓我來看看你的試煉結果吧。");
system("pause");
zt=false;
}
}
}
break;
case 'a':
case 'A':
hero_x--;
if (gamemap.mapMax[hero_y][hero_x] == 1)
{
hero_x++;
printf("撞樹上了!\n");
system("pause");
}
if (gamemap.mapMax[hero_y][hero_x] != 5)
{
if(num%3==0)
{
zt=false;
}
}
gamemap.Initmap();
if (hero_x<0)
{
hero_x = 0;
gamemap.move(hero_y,0);
printf("墻都快被你推倒了,回頭吧!\n");
system("pause");
}
else
{
gamemap.move(hero_y,hero_x);
}
if ((hero_x == 3 && hero_y == 0) )
{
juqing("村長:“七夜,到樹林的那邊找到地域愛琴海他會交給你怎么做!~");
juqing("村長:“順便到藥師和鐵匠那里看看也許會獲得幫助");
system("pause");
}
if ((hero_x == 1 && hero_y == 0) )
{
if (!tj)
{
juqing("鐵匠:“你的爺爺被魔獸襲擊時他的劍遺失在了遠處的樹林中!”");
juqing("鐵匠:“找回那把帝王劍才能被地域愛琴海認可,回來時我還可以幫你強化它”");
system("pause");
}
else
{
if(!qh)
{
juqing("太好了,你終于找到帝王劍了,這下梵天大陸有救了,來我幫你強化了它。");
cout<<"得到 帝王劍(超)"<<endl;
qh=true;
system("pause");
}else
{
juqing("拿著這把劍去征服整個梵天大陸吧");
system("pause");
}
};
}
if ((hero_x == 0 && hero_y == 2) )
{
if (!ys)
{
juqing("藥師:“孩子,這幾瓶藥水帶上防身,打倒怪物得到的魔核我也可以給你制作藥水”");
cout<<"得到 生命藥水*2 魔法藥水*2"<<endl;
ys=true;
system("pause");
}else
{
juqing("藥師:“出了村子就會受到魔獸的襲擊。”");
system("pause");
}
}
if ((hero_x == 19 && hero_y == 1) )
{
if (!tj)
{
juqing("找到遺失的帝王劍。。。");
cout<<"得到 帝王劍"<<endl;
tj=true;
system("pause");
}else
{
juqing("這片地方已經搜索過了");
system("pause");
}
}
if ((hero_x == 15 && hero_y == 10) )
{
if (!qh)
{
juqing("地域愛琴海:“你連個真正的武器都沒有怎么來打仗,去找到真正的帝王劍再來找我完成試煉吧”");
system("pause");
}else
{
if(npcname(hero.getlv())!=boss.getname())
{
juqing("你太弱了,起碼練到5級以后再來找我吧");
system("pause");
}else
{
juqing("很不錯,你現在有資格來挑戰我了,讓我來看看你的試煉結果吧。");
system("pause");
zt=false;
}
}
}
break;
case 'd':
case 'D':
hero_x++;
if (gamemap.mapMax[hero_y][hero_x] == 1)
{
hero_x--;
printf("撞樹上了!\n");
system("pause");
}
if (gamemap.mapMax[hero_y][hero_x] != 5)
{
if(num%3==0)
{
zt=false;
}
}
gamemap.Initmap();
if (hero_x>19)
{
hero_x = 19;
gamemap.move(hero_y,19);
printf("墻都快被你推倒了,回頭吧!\n");
system("pause");
}
else
{
gamemap.move(hero_y,hero_x);
}
if ((hero_x == 3 && hero_y == 0) )
{
juqing("村長:“七夜,到樹林的那邊找到地域愛琴海他會交給你怎么做!~");
juqing("村長:“順便到藥師和鐵匠那里看看也許會獲得幫助");
system("pause");
}
if ((hero_x == 1 && hero_y == 0) )
{
if (!tj)
{
juqing("鐵匠:“你的爺爺被魔獸襲擊時他的劍遺失在了遠處的樹林中!”");
juqing("鐵匠:“找回那把帝王劍才能被地域愛琴海認可,回來時我還可以幫你強化它”");
system("pause");
}
else
{
if(!qh)
{
juqing("太好了,你終于找到帝王劍了,這下梵天大陸有救了,來我幫你強化了它。");
cout<<"得到 帝王劍(超)"<<endl;
qh=true;
system("pause");
}else
{
juqing("拿著這把劍去征服整個梵天大陸吧");
system("pause");
}
};
}
if ((hero_x == 0 && hero_y == 2) )
{
if (!ys)
{
juqing("藥師:“孩子,這幾瓶藥水帶上防身,打倒怪物得到的魔核我也可以給你制作藥水”");
cout<<"得到 生命藥水*2 魔法藥水*2"<<endl;
ys=true;
system("pause");
}else
{
juqing("藥師:“出了村子就會受到魔獸的襲擊。”");
}
}
if ((hero_x == 19 && hero_y == 1) )
{
if (!tj)
{
juqing("找到遺失的帝王劍。。。");
cout<<"得到 帝王劍"<<endl;
tj=true;
system("pause");
}else
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -