游戏背景:
在古老的传说中,有一座五层妖塔,塔中住着魔王和他手下的妖精们。
一日,妖塔中的魔术师决定举办一次祭祀活动,以增强魔王的法力。他们抓来了一个可怜的流浪商人,关在第四层的一个房间里,他被魔术师施了魔法(魔化了),准备拿来当作祭品。
国王听说此事后,派出了一位勇士(就是你),来到了妖塔下面,你的任务是干掉魔王,为国家除害。当然,你不是空手去的,你随身携带一本怪物书(monster_book),每次杀掉怪物之后,你都会获取与怪物相关的数据。在妖塔中,有很多妖怪散落的装备或者药水可以供你使用,还有一些商店(奸商)给你提供商品。
...好了,你自己玩吧...
更新背景:
图腾符文的坐标出了点问题,导致游玩过程中可能崩溃,刚修复...
------------------------------------------------丑不拉叽的分割线---------------------------------------------------------
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define BNUM 17
#define TOWER 5
#define COLS 40
#define LINES 100
#define RUNE 22
struct BLOCKS
{string name;int hp;int attack;int defence;bool go;bool monster;int xp;int number;
};
struct PLAYER
{string name;int hp;int attack;int defence;int tower;int x;int y;int xp;int level;int money;
};
unsigned long long uplevel[]={0,10,25,40,60,80,150,300,400,650,800,950,1100,1200,1500,1800,2000,3100,5000,6500,7900,8900,9700,10000,12000,14000,15860,17738,18939,20039,21950,25910,27830,29382,31829,33849,35939,36788,38193,41829,43829,45888,47361,49382,51853,54830};
BLOCKS map[BNUM][COLS][LINES];
string runec[RUNE]=
{
"魔王在进行一种祭祀仪式(最高机密,不可泄漏),只要集齐了日月的阴阳之力(眼熟吧),就可以召唤^&*!%!%@(字迹不清)",
"吼...",
"妖怪们最喜欢在一层的这个右侧房间玩耍了,因为有卫兵和骑士把守,十分安全...",
"传说中的储物间中,存放着妖精们的武器和神秘药水,不知有何作用...",
"真是个奇怪的骑士,还带着假面,还是不要惹他为好...",
"长满了青苔和杂草的楼梯间,上面还传来了不明的低吼声...",
"魔法师在这里布下重重迷阵,并制造了许多分身,防止有人破坏了祭祀仪式...\n",
"只有通过了迷阵,才能找到下一个楼梯间...\n",
"无数的怪物在里面防守着,可见内部可能藏着什么东西...\n",
"魔王允许一个人类在这里开设商店,并且高价卖破烂,就是为了坑钱...\n",
"迷宫,又是迷宫...\n",
"魔法师:&*#$^!...(消失不见)...\n",
"魔王将魔兽与人类生下的孩子在这里培养,这些孩子长得歪瓜裂枣(很丑),但好像很喜欢打架...\n",
"伪装的魔王在这里等待着客人的来临...\n",
"别想着走捷径,傻瓜...\n",
"传说中的英文字母表(不会的请回幼儿园重读),不过好像并没有那么简单呢...\n",
"一块石碑: 旅行者的血肉,魔术师的魔法,还有被感染的人类,可以召唤 (只有聪明的人才能看见那些东西)...\n",
"只要干掉魔王,就能终止祭祀仪式, 就不会出现...\n",
"阴之月符文: $&^%!!# 聚集月的阴之力...\n",
"阴之日符文:#%^&!$! 聚集日的阴之力...\n",
"阳之日符文:!$!&^%# 聚集日的阳之力...\n",
"阳之月符文:#!!%^&$ 聚集月的阳之力...\n",
};
int rtower[RUNE]={0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,3,4,4,4,4,4,4};
int rposx[RUNE]={2,17,7,4,31,37,1,9,31,1,2,38,2,33,39,2,1,1,16,19,19,22};
int rposy[RUNE]={1,1,3,9,59,97,1,10,1,22,42,97,2,98,92,2,2,3,37,34,40,37};bool DidFile=false;
bool monster_[BNUM]={0};
string sympol=" #shjlmdbzaSftg@";
string Name[BNUM]={"空地","墙","卫兵","骑士","假面骑士","小丑","魔术师","商店","流浪商人_魔化","治疗药水","战斧","盾牌","魔王_假","魔王_真","小鬼","符文"};
int Hp[BNUM]= {0,0,100,200,800,1500,1800,0,1200,0,0,0,3000,6000,500,0};
int Attack[BNUM]= {0,0, 30, 50,220,200, 570,0,400,0,0,0,600,1000,130,0};
int Defence[BNUM]={0,0, 10, 20, 80,120, 220,0,150,0,0,0,350,500,35,0};
bool Go[BNUM]= {1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
bool monster[BNUM]={0,0,1,1,1,1,1,0,1,0,0,0,1,1,1,0};
int Xp[BNUM]={2,0,10,30,60,100,150,0,100,0,0,0,5000,20000,300,10};
PLAYER player;
int sudu=5;
unsigned long long Time,now;
char MAP[TOWER][40][102]=
{{"# ##################################################################################################","# ## s s #z #a #a # #","#@s# a # # h # # # # #","#z ########hh#########s######s#####h##### a #","# # @ # #","# # ##h## ######################## a S S a #","# # #h# #h# #zzs # z #","# s@ # # ### # a S S a #","# #### ##### # # # # #","# #ah # # # # a #","# #hh # # # # #","# ## l lg # # # # #","# # mgm # ### ## ##### hh #","# # g l # # # # # hhhh #","# # # # # # # #############################hh###############","# # # # ########## # # #","# # # # ######### ## # #","#@# ## ##s# # # # # #","#f## ## # #jh# # # # # ## # #","#f # # # #### # # # # # # # #","# ######ss######## # # # # # # # # # #","# hh ## ## # ## # # # # # #","# # ## # # # # #","# # # # # # # # #","# # ##### #### # ## # #","# # # # ## # #","# ####### # # # #","###################################################### # #","# # #","# # #","#################### ######################################h######################## ###############","# # @ j # #","# ####### ##### # # # #","# # # # # # #","# # # # # # #","# # # # # #","# # # # # # # #","# # # # # # # @j#","# ######## #### ####### # # j #","####################################################################################################",},{"# ##################################################################################################","#@# jSaz# # dj @ # #","# # ###### # # # @ #","#h # hs # #### #### ## ##### # #### ###### ####### #","#z# ##################### # # # # # # # # # # # ## # #","#a# z z # # # # # # ##### #### # ###### #","# # z ###hs### l hh h # # # # # # ## # # ## # #","# # z z # sh # l hh # ##################################################### #","# # # # # # # # # # # # ## ## #","##########@######################### # ### # # # # # ## # ### # # #","# ## # #z # # # # ######################## ## # # # # # #","## # #z######### ## # # # # ## # #### ## ## # # # # #","# ##### # # # # l # # # ## # # # # # ## # # #","#z j # #z# # S # # # ## # # # #### ## # # # #","# # z # # ####### # # # ### # m# ## # # ## ##### #","# # # #z#z # ## # # # # ###### ## ###### ## # # # # # # # # #","# ##### # ####### #zz############## # # # # # # ## ## ## # # # #","# z ## #z ## # # # ###### # # ##m #### # # ## # # # #","# z# #z ##########z h# S j j# # # f ## # # # # # #","# z# ## # # ## # # # # # # # #","# # # ################# S # # # #### #### # # # # #","# # z # # # # # # # # #","#########z ############ # # # #### ### # #","# z # # z ############## # # # # # #","# z h h z # jj j# # #### #### # #","#################### ## a # # # # #","# z h zzzz h z # # # # # ##### # #","## ####################a S a # # # # # # # #","# zh aaaaaa hz # # # ### # # ##### # #","#################### ## # # # # # # # #","# hz SSSSSSSS zh # a a # # # # ##### f #","#@#################################### ############## ######################## ####################","#shjjjzsjshjjjjjjhsjsslfjfjjjshljsh #### # #### #### ##### zzzzzzzz #","#sajjjzazjjzSshsajsssh######## ### ###### # # # # # zaaaaaaz #","#hzzsjsjzsjSjsjhjzjjjjshshhhslshhsh #a# # #### ### ##### zSSSSSSz #","#sjzsSzSzsSjjhsahhhhSh######## ### ####a# # # # # # zzzzzzzz #","#sjjsssSzajjjsSjjjsshj#sszhzjahhsms #a# # #### #### ##### #","#hjhzjassssssjssssshjj###########################################################################m##","#jjhsjssjjhsssssjjsssajjjljjjjjjjjj @ #","####################################################################################################",},{"####################################################################################################","# # #","##@g g g g ggggggggggg #","#gg##g#g#g#g#g#######g##########################g###############g################################ #","# g g g g g #","#gg##g#g#g#g#g#########g######################g#################g################################ #","# g g g g g #","#gg##g#g#g#g#g###########g##################g###################g################################ #","# g g g g g #","#gg##g#g#g#g#g#############g##############g#####################g################################ #","# g g g g g #","#gg##g#g#g#g#g###############g##########g#######################g################################ #","# g g g g g #","#gg##g#g#g#g#g#################g######g#########################g##########gggggggggg############ #","# g g g g g #","#gg##g#g#g#g#g###################g##g###########################g################################ #","# g g gg g #","#gg##g#g#g#g#g####################gg############################g##########gggggggggg############ #","# g g g g g #","#gg##g#g#g#g#g##################g####g##########################g################################ #","# g g g g g #","#gg##g#g#g#g#g################g########g########################g################################ #","# g g g g g #","#jj##g#g#g#g#g##############g############g######################g################################ #","# g g g g g #","#jj##g#g#g#g#g############g################g####################g################################ #","# g g g g g #","#jj##g#g#g#g#g##########g####################g##################g################################ #","# g g g g g #","#gg##g#g#g#g#g########g########################g################g################################ #","# g g g g g #","#gg##g#g#g#g#g######g############################g##############g################################ #","# g # z aaaaaa s a @#","## # # zzzzzzz a a a sa zzz#","# # # z z z a aa a zs zzz#","## ##z zzz z aaaa z s #z#","# # # z aaaaa #z#","# # ###########################################################################################f#","# # @mlfff #","####################################################################################################",},{"####################################################################################################","# j a # # # # #","#j@ a a # bggg # zzz # mmmm # #","# a a # g g # z z # l m # jjjjjj #","# aaaaaaa g gggg g z # l m # j #","# a a # g g # z z l l d m l jjjjj #","# a a # g g # zzzz # l m # j #","# # ggggg # # l m # j #","# # # # mmmmm # jjjjjjj #","# # # # # #","##########################################################################################l#########","# # # # # #","# # # # # #","# # # jjjjjj # # # # # ######## #","# # # j # # # # gggggg # # #","# # # j # # # # g g # # #","# # # # j # ###### # # g # # #","# # # j # # # # j g gggggg g ###### #","# ### # j j # # # # # g g # # #","# # # # jj # # # # # g g # # #","# # # # # # # # # # ggggggg # # #","# # # # # # # #","# # # # # #","###### #############################################################################################","# # # # # #","# l # # # # # jj # ##### #","# l # # ## # # j j # # # #","# l # # # # # # j j # ##### #","# l # # # # # j j # #","# l # # # # # # j j # # #","# l l # # # ## # jjj # # #","# llllllll # # # # # # #","# # # # # #","######## ################# ##################### ##################### ################### #########","# # # #m## # zzzz # lll #","# g g # ##### # # # z z # l l #","# g g # # # # zzz # l ll #","# g g # # # #### # z z # llll #","# ggg g # # # # # # # l #","####################################################################################################",},{"####################################################################################################","# @@ m # ##","### mmm # # #","# # # # # # # #","# # # # # # #","# # # # # # # #","# # # # # # #","# # # # # # # #","# # #a a# # # #","# # # aa aa # # # # #","# # # aaa aaaa aaa # # # #","# # # aaaa # # # # #","# # # aaaa # # # #","# # #z aaaa z# # # # #","# # # z z # # # #","# # # z z # # # # #","# # # z ###@### z # # # #","# # # zzzz # # zzzzz # # # # #","# m m zzzz # fff # z zzzz mm # #","# mmm zzzzz @ ftf @ z zzzz mm mm #","# mmm zzzz z# fff #z zzzz mm mm #","# m m a # # a mm # #","# # # a ###@### a # # # # #","# # # a a # # # #","# # # a a # # # # #","# # # a zzzz a # # # #","# # # aSSS zzzz SSSa # # # # #","# # # SS zzzz SS # # # #","# # #S zzzz S# # # # #","# # # # # # #","# # # # # # # #","# # # # # # #","# # # # # # # #","# # # # # # #","# # # # # # # #","# # # # # # #","# # # # # # # #","# # mmm # # #","## m # ##","####################################################################################################",},
};
int tower=0;
void addlevels();
int AttAck(int attack);
void AttackMonster();
void color(int x);
void cls();
void coutwhat(int a,int b,int c,int d,string n);
void Die();
void game();
char getin(char x,char y);
void gotoxy(int y,int x);
void gs();
void hidden();
void init();
void monsterbook();
void PrintfMap(int x);
int random(int n,int m);
void rf();
void Sout(string n);
void wf();
void shop();
void bnm();
void monsterbook()
{cls();int i,j,k;for(i=0;i
int AttAck(int attack)
{int i&#61;0,j&#61;1;gotoxy(10,0);cout<<"按空格攻击\n";cout<<"Low High Low\n";cout<<"------------------------------------------------------------\n\n";cout<<"------------------------------------------------------------";float shang[60]&#61;{0.1,0.1,0.1,0.2,0.2,0.2,0.2,0.3,0.3,0.3,0.3,0.5,0.5,0.5,0.6,0.6,0.6,0.7,0.7,0.7,0.7,0.7,0.8,0.9,0.9,1.0,1.2,1.5,2.0,1.5,1.2,0.9,0.9,0.8,0.8,0.7,0.7,0.7,0.7,0.6,0.6,0.6,0.5,0.5,0.5,0.4,0.4,0.4,0.3,0.2,0.2,0.2,0.2,0.1,0.1,0.1,0.6,0.4,0.4,0.1};while(1){gotoxy(13,i-j);cout<<" ";gotoxy(13,i);cout<<"|#|";char m;if (kbhit()){m&#61;getch();if (m&#61;&#61;&#39; &#39;)return attack*(shang[i])&#43;attack*0.3;}i&#43;&#61;j;if (i>&#61;60)j&#61;-j;if (i<&#61;0)j&#61;-j;Sleep(1);}
}
void init()
{int i,j,k,I;Time&#61;time_t();printf("初始化请稍等...");for(I&#61;0;I
void coutwhat(int a,int b,int c,int d,string n)//输出一些东西&#xff0c;从坐标(a,b)到(c,d)输出n
{int i,j;for(i&#61;a;i<&#61;c;i&#43;&#43;){gotoxy(i,b);for(j&#61;b;j<&#61;d;j&#43;&#43;){cout<
void gotoxy(int y,int x) //移动光标
{COORD coord; coord.X&#61;x; coord.Y&#61;y;HANDLE a&#61;GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(a,coord);
}
void color(int x)//调颜色
{switch(x){case 0:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);break;case 1:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_GREEN);break;case 2:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_BLUE |FOREGROUND_GREEN);break;case 3:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_BLUE |FOREGROUND_GREEN);break;case 4:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_BLUE);break;case 5:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_BLUE |FOREGROUND_RED);break;case 7:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_RED);break;case 8:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_RED|FOREGROUND_GREEN);break;case 9:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_RED|FOREGROUND_BLUE);break;case 10:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_RED);break;default:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY|FOREGROUND_BLUE);break;}
}
char getin(char x,char y)
{char l;dol&#61;_getch();while(l
}
int random(int n,int m)
{int s;s&#61;rand()%(m-n&#43;1);s&#43;&#61;n;return s;
}
void cls()
{system("cls");
}
void shop()
{cls();int much[10]&#61;{30,50,120,30,50,150,30,50,120};while(1){printf("欢迎&#xff0c;你想买些什么&#xff1f;");printf("1.锈迹斑斑的铁剑 (attack&#43;3) $30\n");printf("2.崭新的铁剑 (attack&#43;5) $50\n");printf("3.银光闪闪的宝剑 (attack&#43;12) $120\n");printf("4.发霉的药水 (hp&#43;20) $30\n");printf("5.普通的药水 (hp&#43;40) $50\n");printf("6.高级药水 (hp&#43;500 attack&#43;10) $150\n");printf("7.破烂盾牌 (defence&#43;1) $30\n");printf("8.木头盾牌 (defence&#43;2) $50\n");printf("9.坚固的铁盾(defence&#43;4) $120\n");printf("0.离开 $0\n");char n&#61;_getch();if (n&#61;&#61;&#39;0&#39;)break;printf("确定买%c吗?Y/N",n);char m&#61;_getch();if (m&#61;&#61;&#39;N&#39;||m&#61;&#61;&#39;n&#39;)continue;if (player.money
void Sout(string n)
{for(int i&#61;0;i
void hidden()
{
HANDLE handle &#61; GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursorInfo;GetConsoleCursorInfo(handle, &CursorInfo);
CursorInfo.bVisible &#61; false;
SetConsoleCursorInfo(handle, &CursorInfo);
}
void gs()
{hidden();gotoxy(45,80);cout<<"按下任意键继续_";_getch();system("cls");
}
void PrintfMap(int x)
{cls();gotoxy(0,0);int i,j;for(i&#61;0;i<40;i&#43;&#43;){for(j&#61;0;j<100;j&#43;&#43;){printf("%c",MAP[x][i][j]);}printf("\n");}for(i&#61;0;i
void Die()
{cls();sudu&#61;150;Sout("你\t死\t了");sudu&#61;10;exit(0); gs();rf();
}
void AttackMonster(int x,int y)
{cls();BLOCKS j;char l;int n,m;j&#61;map[player.tower][player.x][player.y];n&#61;player.attack;player.attack*&#61;0.9;//考虑玩家不一定全部能正中 if (j.attack-player.defence>0){m&#61;player.hp/(j.attack-player.defence);if (player.attack-j.defence<&#61;0){printf("你现在可能还打不过他呢&#xff0c;是否继续挑战&#xff1f;Y.yes N.no");l&#61;_getch();player.attack&#61;n;if (l&#61;&#61;&#39;n&#39;||l&#61;&#61;&#39;N&#39;){PrintfMap(player.tower);player.x&#61;x,player.y&#61;y;return;}}m*&#61;(player.attack-j.defence);if (m<&#61;j.hp){printf("你现在可能还打不过他呢&#xff0c;是否继续挑战&#xff1f;Y.yes N.no");l&#61;_getch();player.attack&#61;n;if (l&#61;&#61;&#39;n&#39;||l&#61;&#61;&#39;N&#39;){PrintfMap(player.tower);player.x&#61;x,player.y&#61;y;return;}}}player.attack&#61;n;while(j.hp>0&&player.hp>0){cls();printf("敌人:%s\n",j.name.c_str());printf("敌人的血量:%d\n",j.hp);printf("敌人的攻击:%d\n",j.attack);printf("敌人的防御:%d\n",j.defence);printf("你的血量:%d\n",player.hp);printf("你的攻击:%d\n",player.attack);printf("你的防御:%d\n",player.defence); printf("1.attack 2.run away\n");l&#61;_getch();if (l&#61;&#61;&#39;2&#39;)if (rand()%4&#61;&#61;1&&j.name!&#61;"魔术师"&&j.name!&#61;"魔王_真"){map[player.tower][player.x][player.y].hp&#61;j.hp;return;}elseprintf("逃跑失败!");n&#61;AttAck(player.attack);n-&#61;j.defence;j.hp-&#61;n;if (n<&#61;0)n&#61;1;printf("你发起了攻击&#xff0c;%s受到了%d点伤害!\n",j.name.c_str(),n);n&#61;j.attack*random(9,12)/10.0;n-&#61;player.defence;if (n<&#61;0)n&#61;1;player.hp-&#61;n;printf("%s发起了攻击&#xff0c;你受到了%d点伤害!\n",j.name.c_str(),n);gs();}if (player.hp<&#61;0)Die();if (map[player.tower][player.x][player.y].name&#61;&#61;"魔王_真"){system("cls");Sout("你成功打败了魔王&#xff0c;游戏结束&#xff0c;你赢了!");exit(0);}if (map[player.tower][player.x][player.y].name&#61;&#61;"流浪商人_魔化")map[player.tower][player.x][player.y].name&#61;"流浪商人";map[player.tower][player.x][player.y].hp&#61;0;map[player.tower][player.x][player.y].attack&#61;0;map[player.tower][player.x][player.y].defence&#61;0;map[player.tower][player.x][player.y].go&#61;1;map[player.tower][player.x][player.y].monster&#61;0;monster_[map[player.tower][player.x][player.y].number]&#61;1;player.money&#43;&#61;Xp[map[player.tower][player.x][player.y].number];MAP[player.tower][player.x][player.y]&#61;&#39; &#39;;PrintfMap(player.tower);return;
}
void addlevels()
{while(player.xp>uplevel[player.level])player.level&#43;&#43;,player.hp&#43;&#61;80,player.attack&#43;&#61;6,player.defence&#43;&#61;3;
}
void game()
{char l;int i,j,k,n,m;while(player.tower
}
int main()
{char l;int i,j,k;hidden();init();game();return 0;
}