#include <bits/stdc++.h>
#include <conio.h>
#include <windows.h>
#include <unistd.h>
#define Map_lenght 20
#define Map_width 15
#define WALL_DATA 1
#define PLAYER_DATA 2
#define AIR_DATA 0
#define WALL_VIEW "■"
#define AIR_VIEW " "
#define cursor "->"
#define up 119
#define down 115
#define right 100
#define left 97
#define esc 27
#define enter 13
#define tab 9
#define Backspace 8
#define speed 100.0000f
using namespace std;
int bag_price[100] = { 0 };
string bag_name[100];
string bag_attribute[100];
bool bag_Equipped[100];//0->未装备 1->装备
int money = 2000;
string all_name[] = {"武士","射手","战士","刺客","法师","精灵"}; // 职业的名字 = my_whole_name
string name[] = {"武","射","战","刺","法","精"}; // 职业的图标 = my_name
int evade[] = {30,10,20,25,10,40}; // 闪避率 = my_evade
int len = sizeof(all_name)/sizeof(all_name[0]); // 长度
int Critical_hit_rate[] = {20,30,40,50,20,30}; // 暴击率 = my_hit_rate
int Life_value[] = {300,200,250,100,150,500}; // 生命值 = blood
int Injury_free_rate[] = {40,20,30,10,20,30}; // 免伤率 = my_Injury_free_rate
int Hurt[] = {25,30,20,40,35,10}; // 伤害值 = my_hurt
int physical_strength[] = {155,120,130,160,100,170}; // 体力值 = my_physical_strength
string jineng[] = {"正义之盾","寒冰之箭","神龙之斩","暗之突袭","闪电法阵"};
int blood_plus[] = {100,150,200,250,300};
int money_plus[] = {1000,1500,2000,2500,3000};
int jineng_Hurt[] = {0,500,400,650,600};
int myI;
string all_weapon[] = {"长剑","寒光剑","青藤剑","幻彩流剑","极电霹雳剑","赤龙神焱剑","龙☆紫电塞维枪","魔☆神源悔毒枪","天神★远古圣器"};
int all_weapon_price[] = {50,100,289,372,500,1000,2000,4000,5000};
int Injury_value[] = {10,20,30,50,100,300,500,700,1000};
string Weapon_attribute[] = {"普","寒","青","彩","电","火","龙","魔","神"};
int weapon_len = sizeof(all_weapon)/sizeof(all_weapon[0]);
int xlc_monster[] = {0,0,0,0};//0->存在 1->不存在
string all_aromr[] = {"木盾","铁盾","金盾","亮金盾","极地寒魄甲","复活甲","双龙傲世甲","万世红莲甲","传说龙魂甲"}; //防具名称
int Defense_value[] = {1,2,3,5,10,0,20,30,40,50}; //防御值
int Armor_price[] = {100,200,300,500,1000,2000,4000,6000,10000}; //防具价钱
string Armor_property[] = {"木","铁","金","金","寒","复活","龙","火","龙"};
int armor_len = sizeof(all_aromr)/sizeof(all_aromr[0]);
int Map[Map_width][Map_lenght] = { 0 };
int monster_Alive=0;
string Alive_monster_name[3];
int Alive_monster_information[3][6];
int Year,Mon,Day,Hour,Min,Sec,WDay;
int frequency[6] = { 5 };
struct monster
{
string all_name;
string name;
int shengming;
int drop;
int shanghai;
int mianshang;
int shanbi;
int baoji;
int x;
int y;
}mon[6][4]=
{
{
{"普通僵尸" /*全名*/,"僵"/*地图输出*/,100/*生命*/,100/*掉落*/,20/*伤害*/,10/*免伤*/,20/*闪避*/,5/*暴击*/,4/*怪兽的x*/,5/*怪兽的y*/},
{"普通蜘蛛" /*全名*/,"蛛"/*地图输出*/,200/*生命*/,60/*掉落*/,10/*伤害*/,30/*免伤*/,40/*闪避*/,10/*暴击*/,3/*怪兽的x*/,4/*怪兽的y*/},
{"普通史莱姆"/*全名*/,"史"/*地图输出*/,250/*生命*/,80/*掉落*/,30/*伤害*/,20/*免伤*/,20/*闪避*/,15/*暴击*/,4/*怪兽的x*/,1/*怪兽的y*/},
{"普通骷髅" /*全名*/,"骷"/*地图输出*/,300/*生命*/,140/*掉落*/,40/*伤害*/,30/*免伤*/,40/*闪避*/,18/*暴击*/,6/*怪兽的x*/,4/*怪兽的y*/},
},
{
{"初级僵尸" /*全名*/,"僵"/*地图输出*/,200/*生命*/,200/*掉落*/,50/*伤害*/,30/*免伤*/,30/*闪避*/,10/*暴击*/,4/*怪兽的x*/,5/*怪兽的y*/},
{"初级蜘蛛" /*全名*/,"蛛"/*地图输出*/,350/*生命*/,120 /*掉落*/,30/*伤害*/,40/*免伤*/,50/*闪避*/,15/*暴击*/,7/*怪兽的x*/,3/*怪兽的y*/},
{"初级史莱姆"/*全名*/,"史"/*地图输出*/,450/*生命*/,80/*掉落*/ ,50/*伤害*/,60/*免伤*/,70/*闪避*/,23/*暴击*/,4/*怪兽的x*/,1/*怪兽的y*/},
{"初级骷髅" /*全名*/,"骷"/*地图输出*/,500/*生命*/,160/*掉落*/ ,60/*伤害*/,40/*免伤*/,60/*闪避*/,20/*暴击*/,6/*怪兽的x*/,2/*怪兽的y*/},
},
{
{"中级僵尸" /*全名*/,"僵"/*地图输出*/,250/*生命*/,260/*掉落*/,80/*伤害*/,50/*免伤*/,20/*闪避*/,15/*暴击*/,4/*怪兽的x*/,5/*怪兽的y*/},
{"中级蜘蛛" /*全名*/,"蛛"/*地图输出*/,500/*生命*/,200/*掉落*/,70/*伤害*/,40/*免伤*/,30/*闪避*/,20/*暴击*/,7/*怪兽的x*/,3/*怪兽的y*/},
{"中级史莱姆"/*全名*/,"史"/*地图输出*/,550/*生命*/,120/*掉落*/,70/*伤害*/,60/*免伤*/,50/*闪避*/,25/*暴击*/,4/*怪兽的x*/,1/*怪兽的y*/},
{"中级骷髅" /*全名*/,"骷"/*地图输出*/,600/*生命*/,180/*掉落*/,80/*伤害*/,40/*免伤*/,30/*闪避*/,26/*暴击*/,6/*怪兽的x*/,2/*怪兽的y*/},
},
{
{"高级僵尸" /*全名*/,"僵"/*地图输出*/,500/*生命*/,460/*掉落*/,100/*伤害*/,60/*免伤*/,30/*闪避*/,23/*暴击*/,4/*怪兽的x*/,5/*怪兽的y*/},
{"高级蜘蛛" /*全名*/,"蛛"/*地图输出*/,600/*生命*/,280/*掉落*/,120/*伤害*/,50/*免伤*/,40/*闪避*/,25/*暴击*/,7/*怪兽的x*/,3/*怪兽的y*/},
{"高级史莱姆"/*全名*/,"史"/*地图输出*/,650/*生命*/,380/*掉落*/,130/*伤害*/,40/*免伤*/,50/*闪避*/,35/*暴击*/,4/*怪兽的x*/,1/*怪兽的y*/},
{"高级骷髅" /*全名*/,"骷"/*地图输出*/,700/*生命*/,580/*掉落*/,150/*伤害*/,50/*免伤*/,20/*闪避*/,38/*暴击*/,6/*怪兽的x*/,2/*怪兽的y*/},
},
{
{"僵尸巨怪" /*全名*/,"僵"/*地图输出*/,600/*生命*/,660/*掉落*/,200/*伤害*/,40/*免伤*/,40/*闪避*/,30/*暴击*/,4/*怪兽的x*/,5/*怪兽的y*/},
{"蜘蛛巨怪" /*全名*/,"蛛"/*地图输出*/,650/*生命*/,480/*掉落*/,180/*伤害*/,20/*免伤*/,30/*闪避*/,35/*暴击*/,7/*怪兽的x*/,3/*怪兽的y*/},
{"史莱姆巨怪"/*全名*/,"史"/*地图输出*/,780/*生命*/,460/*掉落*/,190/*伤害*/,30/*免伤*/,40/*闪避*/,45/*暴击*/,4/*怪兽的x*/,1/*怪兽的y*/},
{"骷髅巨怪" /*全名*/,"骷"/*地图输出*/,730/*生命*/,700/*掉落*/,230/*伤害*/,20/*免伤*/,40/*闪避*/,40/*暴击*/,6/*怪兽的x*/,2/*怪兽的y*/},
},
{
{"终极僵尸" /*全名*/,"僵"/*地图输出*/,1000/*生命*/,1000/*掉落*/,400/*伤害*/,50/*免伤*/,30/*闪避*/,35/*暴击*/,4/*怪兽的x*/,5/*怪兽的y*/},
{"终极蜘蛛" /*全名*/,"蛛"/*地图输出*/,1200/*生命*/,1200/*掉落*/,300/*伤害*/,30/*免伤*/,50/*闪避*/,45/*暴击*/,7/*怪兽的x*/,3/*怪兽的y*/},
{"终极史莱姆"/*全名*/,"史"/*地图输出*/,1300/*生命*/,1400/*掉落*/,500/*伤害*/,40/*免伤*/,20/*闪避*/,55/*暴击*/,4/*怪兽的x*/,1/*怪兽的y*/},
{"终极骷髅" /*全名*/,"骷"/*地图输出*/,1500/*生命*/,1600/*掉落*/,600/*伤害*/,40/*免伤*/,20/*闪避*/,65/*暴击*/,6/*怪兽的x*/,2/*怪兽的y*/},
}
},m[6][4]=
{
{
{"普通僵尸" /*全名*/,"僵"/*地图输出*/,100/*生命*/,100/*掉落*/,20/*伤害*/,10/*免伤*/,20/*闪避*/,5/*暴击*/,4/*怪兽的x*/,5/*怪兽的y*/},
{"普通蜘蛛" /*全名*/,"蛛"/*地图输出*/,200/*生命*/,60/*掉落*/,10/*伤害*/,30/*免伤*/,40/*闪避*/,10/*暴击*/,3/*怪兽的x*/,4/*怪兽的y*/},
{"普通史莱姆"/*全名*/,"史"/*地图输出*/,250/*生命*/,80/*掉落*/,30/*伤害*/,20/*免伤*/,20/*闪避*/,15/*暴击*/,4/*怪兽的x*/,1/*怪兽的y*/},
{"普通骷髅" /*全名*/,"骷"/*地图输出*/,300/*生命*/,140/*掉落*/,40/*伤害*/,30/*免伤*/,40/*闪避*/,18/*暴击*/,6/*怪兽的x*/,4/*怪兽的y*/},
},
{
{"初级僵尸" /*全名*/,"僵"/*地图输出*/,200/*生命*/,200/*掉落*/,50/*伤害*/,30/*免伤*/,30/*闪避*/,10/*暴击*/,4/*怪兽的x*/,5/*怪兽的y*/},
{"初级蜘蛛" /*全名*/,"蛛"/*地图输出*/,350/*生命*/,120 /*掉落*/,30/*伤害*/,40/*免伤*/,50/*闪避*/,15/*暴击*/,7/*怪兽的x*/,3/*怪兽的y*/},
{"初级史莱姆"/*全名*/,"史"/*地图输出*/,450/*生命*/,80/*掉落*/ ,50/*伤害*/,60/*免伤*/,70/*闪避*/,23/*暴击*/,4/*怪兽的x*/,1/*怪兽的y*/},
{"初级骷髅" /*全名*/,"骷"/*地图输出*/,500/*生命*/,160/*掉落*/ ,60/*伤害*/,40/*免伤*/,60/*闪避*/,20/*暴击*/,6/*怪兽的x*/,2/*怪兽的y*/},
},
{
{"中级僵尸" /*全名*/,"僵"/*地图输出*/,250/*生命*/,260/*掉落*/,80/*伤害*/,50/*免伤*/,20/*闪避*/,15/*暴击*/,4/*怪兽的x*/,5/*怪兽的y*/},
{"中级蜘蛛" /*全名*/,"蛛"/*地图输出*/,500/*生命*/,200/*掉落*/,70/*伤害*/,40/*免伤*/,30/*闪避*/,20/*暴击*/,7/*怪兽的x*/,3/*怪兽的y*/},
{"中级史莱姆"/*全名*/,"史"/*地图输出*/,550/*生命*/,120/*掉落*/,70/*伤害*/,60/*免伤*/,50/*闪避*/,25/*暴击*/,4/*怪兽的x*/,1/*怪兽的y*/},
{"中级骷髅" /*全名*/,"骷"/*地图输出*/,600/*生命*/,180/*掉落*/,80/*伤害*/,40/*免伤*/,30/*闪避*/,26/*暴击*/,6/*怪兽的x*/,2/*怪兽的y*/},
},
{
{"高级僵尸" /*全名*/,"僵"/*地图输出*/,500/*生命*/,460/*掉落*/,100/*伤害*/,60/*免伤*/,30/*闪避*/,23/*暴击*/,4/*怪兽的x*/,5/*怪兽的y*/},
{"高级蜘蛛" /*全名*/,"蛛"/*地图输出*/,600/*生命*/,280/*掉落*/,120/*伤害*/,50/*免伤*/,40/*闪避*/,25/*暴击*/,7/*怪兽的x*/,3/*怪兽的y*/},
{"高级史莱姆"/*全名*/,"史"/*地图输出*/,650/*生命*/,380/*掉落*/,130/*伤害*/,40/*免伤*/,50/*闪避*/,35/*暴击*/,4/*怪兽的x*/,1/*怪兽的y*/},
{"高级骷髅" /*全名*/,"骷"/*地图输出*/,700/*生命*/,580/*掉落*/,150/*伤害*/,50/*免伤*/,20/*闪避*/,38/*暴击*/,6/*怪兽的x*/,2/*怪兽的y*/},
},
{
{"僵尸巨怪" /*全名*/,"僵"/*地图输出*/,600/*生命*/,660/*掉落*/,200/*伤害*/,40/*免伤*/,40/*闪避*/,30/*暴击*/,4/*怪兽的x*/,5/*怪兽的y*/},
{"蜘蛛巨怪" /*全名*/,"蛛"/*地图输出*/,650/*生命*/,480/*掉落*/,180/*伤害*/,20/*免伤*/,30/*闪避*/,35/*暴击*/,7/*怪兽的x*/,3/*怪兽的y*/},
{"史莱姆巨怪"/*全名*/,"史"/*地图输出*/,780/*生命*/,460/*掉落*/,190/*伤害*/,30/*免伤*/,40/*闪避*/,45/*暴击*/,4/*怪兽的x*/,1/*怪兽的y*/},
{"骷髅巨怪" /*全名*/,"骷"/*地图输出*/,730/*生命*/,700/*掉落*/,230/*伤害*/,20/*免伤*/,40/*闪避*/,40/*暴击*/,6/*怪兽的x*/,2/*怪兽的y*/},
},
{
{"终极僵尸" /*全名*/,"僵"/*地图输出*/,1000/*生命*/,1000/*掉落*/,400/*伤害*/,50/*免伤*/,30/*闪避*/,35/*暴击*/,4/*怪兽的x*/,5/*怪兽的y*/},
{"终极蜘蛛" /*全名*/,"蛛"/*地图输出*/,1200/*生命*/,1200/*掉落*/,300/*伤害*/,30/*免伤*/,50/*闪避*/,45/*暴击*/,7/*怪兽的x*/,3/*怪兽的y*/},
{"终极史莱姆"/*全名*/,"史"/*地图输出*/,1300/*生命*/,1400/*掉落*/,500/*伤害*/,40/*免伤*/,20/*闪避*/,55/*暴击*/,4/*怪兽的x*/,1/*怪兽的y*/},
{"终极骷髅" /*全名*/,"骷"/*地图输出*/,1500/*生命*/,1600/*掉落*/,600/*伤害*/,40/*免伤*/,20/*闪避*/,65/*暴击*/,6/*怪兽的x*/,2/*怪兽的y*/},
}
};
int last_c;
/*玩家的变量*/
string my_name;
string my_whole_name;
int my_evade;
int my_hit_rate;
int blood=0;
int my_Injury_free_rate;
int my_hurt;
int my_physical_strength;
int const my_physical_strength_top=3000;
int blood_top;
int my_armor;
int Checkpoint=0; //关卡 0-5
int BetType;
int a,b,cd,BetMoney;
int DealerMoney=1000;
int Player_x; //玩家的x
int Player_y; //玩家的y
int cursor_x; //光标的x
int cursor_y; //光标的y
int _cursor; //光标的复变量
void zy(); //家(zy)
void zy_animation(); //家(zy)的动画
void zy_print(); //家(zy)内容的打印
void zy_inspect(); //家(zy)的判断人物是否走到传送门
void home(); //睡觉
void yx(); //游戏(yx)
void yx_Choice(); //游戏(yx)的选择
void yx_animation(); //游戏(yx)的动画
void play(); //赌博机
void Guess(); //猜数字
void Throw(); //投抛色子
int Judge(int a,int b,int c);
void MoneyCalc();
int GetAmount();
void tuichu();
void sd(); //商店(sd)
void sd_inspect(); //商店(sd)的判断人物是否走到传送门
void sd_animation(); //商店(sd)的动画
void weapon(); //武器商店
void armor(); //防具商店
void gs(); //怪兽(gs)
void j_moster(int a,int b); //遇见怪兽
int find_if_monster(int a,int b); //寻找怪兽
void print_moster(bool l); //打印怪兽
void gs_inspect(); //怪兽(gs)的判断人物是否走到传送门
void print_bag();
void printf_Blank_space(int c); //打印空格
int bag_traversal(); //找到第一个没有武器/防具的下标
int Output_or_not(int a); //打印武器/防具还是不打印
int Is_the_weapon_repeated(int n); //查找武器是否重复
int Len(int z);
//其他
void HideCursor(); //隐藏光标
void Choice_of_occupation(); //选择职业
void init(); //初始化
void Draw_Map(); //画地图
void gotoxy(int x,int y); //移动光标函数
void go(int x,int y); //画地图专用移动光标
void Player_move(); //玩家移动
void print_map(int width,int lenght,string s,int a);//输出大小格式为高度:width,宽度:lenght,墙的形状:s,a=0=输出墙壁,a=1=不输出墙壁
void CaiDan(); //菜单
void inspect(); //主页的的判断人物是否走到传送门
void player_moveont(int x,int y,int n); //玩家移动(x->移动最大x-1|y->移动最大y-1)
void set_console_color(unsigned short color_index); //设置控制台颜色
void back_to_zy(); //返回主页
void hospital(); //医院
void case_player(int a); //按照上一次按键将角色移动
void GetTime(); //获取时间
void physical_strength_died(); //因为体力值不足而死的界面
void blood_died(); //因为生命值不足而死的界面
void start(); //开始界面
void Victory_interface(); //胜利界面
void chonglai(); //重来
void Game_set(); //设置
void print(const string a)
{
size_t len = a.size();
for(int i = 0; i < len; i++)
{
cout << a[i];
Sleep(100);
}
}
int c;
HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);//hout获取控制台句柄
int main()
{
srand(time(NULL));//设置随机数种子
system("mode con cols=90 lines=28");//设置窗口大小
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);//设置字体颜色
init();//初始化
CONSOLE_CURSOR_INFO cursor_info={1,0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);//隐藏光标
start();
sleep(1);
Choice_of_occupation();//选择职业
Draw_Map();//画主页地图
while(1)//无限循环
{
Player_move();//玩家移动
inspect();//判断玩家是否走到传送门
Sleep(speed);//停止程序运行=玩家速度
}
return 0;//返回0
}
void init()//初始化
{
Player_x = 2;//玩家x=2
Player_y = 7;//玩家y=7
Map[Player_y][Player_x] = PLAYER_DATA;//地图中的玩家x|玩家y就是玩家
SetConsoleTitle("元气骑士");//设置控制台名字
for(int i=0;i<Map_width;i++)//遍历每行
{
for(int j=0;j<Map_lenght;j++)//遍历每列
{
if(i==0||i==Map_width-1||j==0||j==Map_lenght-1)//如果是地图边缘
{
Map[i][j] = WALL_DATA;//地图i|j
}
else
{
Map[i][j] = AIR_DATA;
}
}
}
}
void Draw_Map()
{
system("cls");
for(int i=0;i<Map_width;i++)
{
for(int j=0;j<Map_lenght;j++)
{
switch(Map[i][j])
{
case WALL_DATA:
printf(WALL_VIEW);
break;
case AIR_DATA:
printf(AIR_VIEW);
break;
case PLAYER_DATA:
set_console_color(243);
cout<<my_name;
set_console_color(15);
break;
}
}
cout<<endl;
}
go(3,2);
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_BLUE);
printf("■");
go(9,7);
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED);
printf("■");
go(16,2);
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_GREEN);
printf("■");
go(3,12);
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_RED);
printf("■");
go(16,12);
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
printf("■");
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
gotoxy(16,15);
printf("村庄中心");
gotoxy(44,1);
cout<<"职业:"<<my_whole_name<<endl;
gotoxy(44,2);
cout<<"血量:"<<blood<<endl;
gotoxy(44,3);
cout<<"血量上限:"<<blood_top<<endl;
gotoxy(44,4);
cout<<"体力值:"<<my_physical_strength<<endl;
gotoxy(44,5);
cout<<"体力值上限:"<<my_physical_strength_top<<endl;
gotoxy(44,6);
cout<<"伤害值:"<<my_hurt<<endl;
gotoxy(44,8);
cout<<"闪避率:"<<my_evade<<"%"<<endl;
gotoxy(44,9);
cout<<"暴击率:"<<my_hit_rate<<"%"<<endl;
gotoxy(44,10);
cout<<"免伤率:"<<my_Injury_free_rate<<"%"<<endl;
gotoxy(44,12);
cout<<"宝石:"<<money<<endl;
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
gotoxy(15,17);
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED);
printf("■ ");
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
printf("→ 家");
/********************************************************************************/
gotoxy(15,18);
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_BLUE);
printf("■ ");
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
printf("→ 电竞");
/********************************************************************************/
gotoxy(15,19);
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_GREEN);
printf("■ ");
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
printf("→ 医院");
/********************************************************************************/
gotoxy(15,20);
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_RED);
printf("■ ");
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
printf("→ 商店");
/********************************************************************************/
gotoxy(15,21);
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
printf("■ ");
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
printf("→ 怪兽");
}
void gotoxy(int x,int y) //光标移动函数,X表示横坐标,Y表示纵坐标。
{
COORD coord; //使用头文件自带的坐标结构
coord.X=x; //这里将int类型值传给short,不过程序中涉及的坐标值均不会超过short范围
coord.Y=y;
HANDLE a=GetStdHandle(STD_OUTPUT_HANDLE); //获得标准输出句柄
SetConsoleCursorPosition(a,coord); //以标准输出的句柄为参数设置控制台光标坐标
}
void Player_move()
{
c = getch();
switch(c)
{
case up:
if(Map[Player_y-1][Player_x] != WALL_DATA)
{
go(Player_x,Player_y);
printf(" ");
Player_y--;
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
}
break;
case down:
if(Map[Player_y+1][Player_x] != WALL_DATA)
{
go(Player_x,Player_y);
printf(" ");
Player_y++;
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
}
break;
case left:
if(Map[Player_y][Player_x-1] != WALL_DATA)
{
go(Player_x,Player_y);
printf(" ");
Player_x--;
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
}
break;
case right:
if(Map[Player_y][Player_x+1] != WALL_DATA)
{
go(Player_x,Player_y);
printf(" ");
Player_x++;
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
}
break;
case tab:
print_bag();
back_to_zy();
break;
case int(VK_F1):
Game_set();
back_to_zy();
break;
}
}
void Choice_of_occupation()//选职业
{
printf("请选择您的职业:");
gotoxy(4,1);
printf("职业 生命值 体力值 伤害值 免伤率(%%) 暴击率(%%) 闪避率(%%) 图标\n\n");
for(int i=0;i<len;i++)
{
cout<<" "<<all_name[i]<<" "<<Life_value[i]<<" "<<physical_strength[i]<<" "<<Hurt[i]<<" "<<Injury_free_rate[i]<<" "<<Critical_hit_rate[i]<<" "<<evade[i]<<" "<<name[i]<<endl;
}
cursor_x = 3;
cursor_y = 1;
while(1)
{
gotoxy(cursor_y,cursor_x);
printf(cursor);
gotoxy(0,10);
int c = getch();
if(c == 13)
{
break;
}
else if(c == 115)
{
gotoxy(cursor_y,cursor_x);
printf(" ");
cursor_x++;
if(cursor_x == 9)
{
cursor_x = 3;
}
}
else if(c == 119)
{
gotoxy(cursor_y,cursor_x);
printf(" ");
cursor_x--;
if(cursor_x == 2)
{
cursor_x = 8;
}
}
}
_cursor = 3;
_cursor = cursor_x - _cursor;
my_name = name[_cursor];
my_evade = evade[_cursor];
my_hit_rate = Critical_hit_rate[_cursor];
blood = Life_value[_cursor];
blood_top = Life_value[_cursor];
my_Injury_free_rate = Injury_free_rate[_cursor];
my_hurt = Hurt[_cursor];
my_physical_strength = physical_strength[_cursor];
my_whole_name = all_name[_cursor];
myI = _cursor;
gotoxy(10,10);
}
void HideCursor()
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(handle, &CursorInfo);//获取控制台光标信息
CursorInfo.bVisible = false; //隐藏控制台光标
SetConsoleCursorInfo(handle, &CursorInfo);//设置控制台光标状态
}
void go(int x,int y) //光标移动函数,X表示横坐标,Y表示纵坐标。
{
COORD coord; //使用头文件自带的坐标结构
coord.X=x*2; //这里将int类型值传给short,不过程序中涉及的坐标值均不会超过short范围
coord.Y=y;
HANDLE a=GetStdHandle(STD_OUTPUT_HANDLE); //获得标准输出句柄
SetConsoleCursorPosition(a,coord); //以标准输出的句柄为参数设置控制台光标坐标
}
void print_map(int width,int lenght,string s,int a)//输出地图
{
for(int i=0;i<width;i++)
{
for(int j=0;j<lenght;j++)
{
if(i == 0||i == width-1||j == 0||j == lenght-1 && a == 0)
{
cout<<s;
}
else
{
if(a != 0)
{
cout<<s;
}
else
{
printf(" ");
}
}
}
cout<<endl;
}
}
void inspect()
{
if(Player_x == 9 && Player_y == 7)
{
zy();
}
else if(Player_x == 3 && Player_y == 2)
{
yx();
case_player(c);
back_to_zy();
}
else if(Player_x == 16 && Player_y == 2)
{
hospital();
case_player(c);
back_to_zy();
}
else if(Player_x == 3 && Player_y == 12)
{
sd();
}
else if(Player_x == 16 && Player_y == 12)
{
gs();
}
}
void physical_strength_died()
{
system("cls");
set_console_color(772);
gotoxy(20,5);
printf("你因精疲力尽而死....");
set_console_color(112);
chonglai();
}
void blood_died()
{
system("cls");
set_console_color(772);
gotoxy(20,5);
printf("你牺牲了....");
set_console_color(112);
chonglai();
}
void back_to_zy()
{
system("cls");
Draw_Map();
while(1)
{
Player_move();
inspect();
Sleep(100);
}
}
void zy()
{
Player_x = 1;
Player_y = 1;
zy_animation();
sleep(1);
system("cls");
zy_print();
while(1)
{
player_moveont(10,10,1);
zy_inspect();
}
}
void zy_inspect()
{
if(Player_x == 5 && Player_y == 2)
{
home();
}
else if(Player_x == 7 && Player_y == 7)
{
Player_x=9;
Player_y=7;
switch(last_c)
{
case up:
Player_y--;
break;
case down:
Player_y++;
break;
case left:
Player_x--;
break;
case right:
Player_x++;
break;
}
back_to_zy();
}
}
void yx()
{
yx_animation();
sleep(1);
system("cls");
yx_Choice();
}
void yx_Choice()
{
int key;
printf(" 电竞列表 \n");
printf(" 1.赌博机 \n");
printf(" 2.猜数字 \n");
printf(" 3...... \n");
printf(" 4...... \n");
cursor_x=0;
cursor_y=1;
while(1)
{
gotoxy(cursor_x,cursor_y);
printf(cursor);
key=getch();
switch(key)
{
case up:
gotoxy(cursor_x,cursor_y);
printf(" ");
cursor_y--;
if(cursor_y == 0)
cursor_y=4;
break;
case down:
gotoxy(cursor_x,cursor_y);
printf(" ");
cursor_y++;
if(cursor_y == 5)
cursor_y=1;
break;
case enter:
break;
case esc:
break;
}
if(key == enter || key == esc)
break;
}
case_player(::c);
if(key == esc)
back_to_zy();
switch(cursor_y)
{
case 1:
system("cls");
play();
break;
case 2:
system("cls");
Guess();
break;
case 3:
break;
case 4:
break;
}
back_to_zy();
}
void hospital()
{
cursor_x = 3;
cursor_y = 0;
system("cls");
gotoxy(14,0);
printf("战地医院");
gotoxy(2,1);
printf("名称 宝石数 回复生命值 回复体力值");
gotoxy(2,3);
printf("治疗 10 50 0");
gotoxy(2,4);
printf("治疗 30 0 100");
gotoxy(2,5);
printf("治疗 100 50 100");
gotoxy(2,7);
cout<<"当前生命值:"<<blood;
gotoxy(2,8);
cout<<"当前体力值:"<<my_physical_strength;
gotoxy(cursor_y,cursor_x);
printf(cursor);
while(1)
{
gotoxy(2,9);
cout<<"当前宝石:"<<money<<" ";
gotoxy(cursor_y,cursor_x);
printf(cursor);
int c = getch();
if(c == esc)
{
break;
}
switch(c)
{
case up:
gotoxy(cursor_y,cursor_x);
printf(" ");
cursor_x--;
if(cursor_x == 2)
{
cursor_x = 5;
}
break;
case down:
gotoxy(cursor_y,cursor_x);
printf(" ");
cursor_x++;
if(cursor_x == 6)
{
cursor_x = 3;
}
break;
case enter:
switch(cursor_x)
{
case 3:
if(money-10 >= 0)
{
money = money-10;
}
blood = blood+50;
if(blood > blood_top)
{
blood = blood_top;
}
gotoxy(2,7);
cout<<"当前生命值:"<<blood<<" ";
gotoxy(2,8);
cout<<"当前体力值:"<<my_physical_strength<<" ";
break;
case 4:
if(money-30 >= 0)
{
money = money-30;
}
else
{
MessageBox(NULL,"宝石不足!","提示",MB_OK);
break;
}
my_physical_strength = my_physical_strength+100;
if(my_physical_strength > my_physical_strength_top)
{
my_physical_strength = my_physical_strength_top;
}
gotoxy(2,7);
cout<<"当前生命值:"<<blood<<" ";
gotoxy(2,8);
cout<<"当前体力值:"<<my_physical_strength<<" ";
break;
case 5:
if(money-100 >= 0)
{
money = money-100;
}
blood = blood+50;
my_physical_strength = my_physical_strength+100;
if(my_physical_strength > my_physical_strength_top)
{
my_physical_strength = my_physical_strength_top;
}
if(blood > blood_top)
{
blood = blood_top;
}
gotoxy(2,7);
cout<<"当前生命值:"<<blood<<" ";
gotoxy(2,8);
cout<<"当前体力值:"<<my_physical_strength<<" ";
break;
}
break;
}
}
system("cls");
}
void Guess()
{
l:
int key,grade;
system("cls");
printf(" 猜数字等级选择 \n");
printf(" 1.5次机会 |宝石:100 |1-100|\n");
printf(" 2.10次机会|宝石:60 |1-100|\n");
printf(" 3.15次机会|宝石:40 |1-100|\n");
printf(" 4.20次机会|宝石:5 |1-100|\n");
printf(" 当前宝石:%d\n",money);
cursor_x=0;
cursor_y=1;
while(1)
{
gotoxy(cursor_x,cursor_y);
printf(cursor);
key=getch();
switch(key)
{
case up:
gotoxy(cursor_x,cursor_y);
printf(" ");
cursor_y--;
if(cursor_y == 0)
cursor_y=4;
break;
case down:
gotoxy(cursor_x,cursor_y);
printf(" ");
cursor_y++;
if(cursor_y == 5)
cursor_y=1;
break;
case enter:
switch(cursor_y)
{
case 1:
grade = 5;
break;
case 2:
grade = 10;
break;
case 3:
grade = 15;
break;
case 4:
grade = 20;
break;
}
break;
case esc:
system("cls");
break;
}
if(key == enter || key == esc)
break;
}
if(key == esc)
yx_Choice();
srand(time(NULL));
int autn,player,k=grade;
autn=rand()%100+1;
system("cls");
while(1)
{
cin.sync();
cin.clear();
cout<<"请输入:";
cin >> player;
if(player > autn)
{
cout<<"大了"<<endl;
}
else if(player < autn)
{
cout<<"小了"<<endl;
}
else if(player == autn)
{
cout<<"猜对了,+"<<k<<"宝石"<<endl;
switch(k)
{
case 5:
money+=100;
break;
case 10:
money+=60;
break;
case 15:
money+=40;
break;
case 20:
money+=5;
break;
}
sleep(1);
break;
}
if(grade == 1)
{
cout<<"次数已用完,挑战失败"<<endl;
break;
}
grade--;
}
goto l;
}
int Len(int z)
{
return (14-(all_weapon[z].length()/2))*2-11;
}
int mlen(int a)
{
int count=0;
while(a > 0)
{
a = a/10;
count++;
}
return count;
}
void printf_Blank_space(int c)
{
for(int i=0;i<Len(c);i++)
{
printf(" ");
}
}
void sd()
{
system("cls");
sd_animation();
sleep(1);
system("cls");
Player_x = 1;
Player_y = 1;
print_map(10,10,WALL_VIEW,0);
go(Player_y,Player_x);
set_console_color(243);
cout<<my_name;
set_console_color(15);
go(3,2);
printf("武");
go(6,2);
printf("防");
go(6,7);
set_console_color(13);
printf("■");
set_console_color(15);
while(1)
{
player_moveont(10,10,2);
sd_inspect();
}
}
void sd_inspect()
{
if(Player_x == 3 && Player_y == 2)
{
case_player(last_c);
weapon();
print_map(10,10,WALL_VIEW,0);
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
go(3,2);
printf("武");
go(6,2);
printf("防");
go(6,7);
set_console_color(13);
printf("■");
set_console_color(15);
}
if(Player_x == 6 && Player_y == 2)
{
case_player(last_c);
armor();
print_map(10,10,WALL_VIEW,0);
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
go(3,2);
printf("武");
go(6,2);
printf("防");
go(6,7);
set_console_color(13);
printf("■");
set_console_color(15);
}
else if(Player_x == 6 && Player_y == 7)
{
Player_x = 3;
Player_y = 12;
switch(last_c)
{
case up:
Player_y--;
break;
case down:
Player_y++;
break;
case left:
Player_x--;
break;
case right:
Player_x++;
break;
}
back_to_zy();
}
}
void weapon()
{
system("cls");
printf(" 武器商店\n");
printf(" 名字 价钱 攻击力 属性 卖出的价钱\n");
for(int i=0;i<weapon_len;i++)
{
cout<<" "<<all_weapon[i];
printf_Blank_space(i);
cout<<all_weapon_price[i];
//cout<<mlen(Injury_value[i]);
if(i == 0)
{
printf(" ");
}
else if(i == 4)
{
printf(" ");
}
else if(i == weapon_len-1)
{
printf(" ");
}
for(int j=1;j<(15-mlen(Injury_value[i]));j++)
cout<<" ";
cout<<Injury_value[i];
if(i>=0 && i<4)
printf(" ");
else if(i >= 4 && i!=weapon_len-1)
printf(" ");
else
printf(" ");
cout<<Weapon_attribute[i];
printf(" ");
cout<<all_weapon_price[i]/2;
cout<<"\n";
}
cursor_x = 0;
cursor_y = 2;
int x,s,count=0;
while(1)
{
gotoxy(2,12);
cout<<"宝石:"<<money<<" ";
gotoxy(cursor_x,cursor_y);
printf(cursor);
int c = getch();
switch(c)
{
case up:
gotoxy(cursor_x,cursor_y);
printf(" ");
cursor_y--;
if(cursor_y < 2)
{
cursor_y = weapon_len+1;
}
break;
case down:
gotoxy(cursor_x,cursor_y);
printf(" ");
cursor_y++;
if(cursor_y > weapon_len+1)
{
cursor_y = 2;
}
break;
case enter:
count=0;
s= bag_traversal();
x=cursor_y-2;
for(int i=0;i<bag_traversal();i++)
{
if(bag_name[i] == all_weapon[x])
{
count++;
break;
}
}
gotoxy(40,11);printf(" ");
if(count >= 1)
{
gotoxy(40,11);printf("您有这件武器了");
break;
}
if(money-all_weapon_price[x] < 0)
{
MessageBox(NULL,"宝石不足","提示",MB_OK);
break;
}
money-=all_weapon_price[x];
bag_name[s] = all_weapon[x];
bag_price[s] = all_weapon_price[x];
bag_attribute[s] = Weapon_attribute[x];
break;
case esc:
system("cls");
}
if(c == esc)
{
break;
}
}
}
void Game_set()
{
system("cls");
go(2,2);
cout<<"设置: 无敌设置: <否>";
gotoxy(11,3);
cout<<"角色移动速度: <"<<speed<<">";
gotoxy(11,4);
cout<<"取消角色背景: <否>";
gotoxy(11,5);
cout<<"金币设置: <"<<money<<">";
gotoxy(11,6);
cout<<"动画设置: <是>";
}
void armor()
{
system("cls");
printf(" 防具商店\n");
printf(" 名字 价钱 防御力 属性 卖出的价钱\n");
for(int i=0;i<armor_len;i++)
{
cout<<" "<<all_aromr[i];
if(i>=0&&i<3)
{
cout<<" ";
}
else if(i==3||i==5)
{
cout<<" ";
}
else
{
cout<<" ";
}
cout<<Armor_price[i];
if(i>=0 && i<4)
{
cout<<" ";
}
else if(i>=4 && i<8)
{
cout<<" ";
}
else
{
cout<<" ";
}
cout<<Defense_value[i];
if(i>=0&&i<4)
{
cout<<" ";
}
else if(i==4 || i>=6)
{
cout<<" ";
}
else
{
cout<<" ";
}
cout<<Armor_property[i];
if(i!=5)
printf(" ");
else
printf(" ");
cout<<Armor_price[i]/2;
cout<<"\n";
}
cursor_x = 0;
cursor_y = 2;
int x,s,count=0;
while(1)
{
gotoxy(2,12);
cout<<"宝石:"<<money<<" ";
gotoxy(cursor_x,cursor_y);
printf(cursor);
int c = getch();
switch(c)
{
case up:
gotoxy(cursor_x,cursor_y);
printf(" ");
cursor_y--;
if(cursor_y < 2)
{
cursor_y = armor_len+1;
}
break;
case down:
gotoxy(cursor_x,cursor_y);
printf(" ");
cursor_y++;
if(cursor_y > armor_len+1)
{
cursor_y = 2;
}
break;
case enter:
count=0;
s= bag_traversal();
x=cursor_y-2;
for(int i=0;i<bag_traversal();i++)
{
if(bag_name[i] == all_aromr[x])
{
count++;
break;
}
}
gotoxy(40,11);printf(" ");
if(count >= 1)
{
gotoxy(40,11);printf("您有这件防具了");
break;
}
if(money-Armor_price[x] < 0)
{
MessageBox(NULL,"宝石不足","提示",MB_OK);
break;
}
money-=Armor_price[x];
bag_name[s] = all_aromr[x];
bag_price[s] = Armor_price[x];
bag_attribute[s] = Armor_property[x];
break;
case esc:
system("cls");
}
if(c == esc)
{
break;
}
}
}
void print_bag()
{
string n;
int a=0,b=0;int s;
bool l;//l=1 -> 武器 L=0-> 防具
int m;//排行
system("cls");
printf(" 背包\n");
printf(" 名字 价钱 属性 卖出的价钱 装备/未装备\n");
for(int i=0;i<bag_traversal();i++)
{
cout<<" "<<bag_name[i];
gotoxy(21,i+2);
cout<<bag_price[i];
gotoxy(39,i+2);
cout<<bag_attribute[i];
gotoxy(59,i+2);
cout<<bag_price[i]/2;
gotoxy(80,i+2);
if(bag_Equipped[i] == 0)cout<<"[未装备]";
else cout<<"[已装备]";
cout<<endl;
}
cursor_x=1;
cursor_y=2;
_cursor=1;
while(1)
{
a=-1;b=-1;
if(bag_traversal() != 0)
{
gotoxy(cursor_x,cursor_y);
printf(cursor);
}
if(bag_traversal() == 0)
{
gotoxy(30,4);
printf("您还没有物品哦,快去购买吧");
}
int d=getch();
switch(d)
{
case up:
gotoxy(cursor_x,cursor_y);
printf(" ");
cursor_y--;
if(cursor_y < 2)
cursor_y = bag_traversal()+1;
break;
case down:
gotoxy(cursor_x,cursor_y);
printf(" ");
cursor_y++;
if(cursor_y > bag_traversal()+1)
cursor_y = 2;
break;
case enter:
l = 0;
_cursor = 2;
_cursor = cursor_y-_cursor;
if(bag_price[_cursor] == 0)break;
for(int i=0;i<weapon_len;i++)
{
if(all_weapon[i] == bag_name[_cursor])
{
l=1;
m=i;
break;
}
}
for(int i=0;i<armor_len;i++)
{
if(all_aromr[i] == bag_name[_cursor])
{
m=i;
break;
}
}
if(l == 1)
{
for(int i=0;i<weapon_len;i++)
{
for(int j=0;j<bag_traversal();j++)
{
if(all_weapon[i] == bag_name[j] && bag_Equipped[j] == 1 && j!=_cursor)
{
my_hurt-=Injury_value[i];
a=j;
break;
}
}
}
if(a != -1)
{
bag_Equipped[a] = 0;
gotoxy(81,a+2);
printf("未装备");
}
if(bag_Equipped[_cursor] == 0)
my_hurt+=Injury_value[m];
else if(bag_Equipped[_cursor] == 1)
my_hurt-=Injury_value[m];
}
if(l == 0)
{
for(int i=0;i<armor_len;i++)
{
for(int j=0;j<bag_traversal();j++)
{
if(all_aromr[i] == bag_name[j] && bag_Equipped[j] == 1 && j!=_cursor)
{
b=j;
my_Injury_free_rate-=Defense_value[i];
break;
}
}
}
if(b != -1)
{
bag_Equipped[b] = 0;
gotoxy(81,b+2);
printf("未装备");
}
if(bag_Equipped[_cursor] == 0)
my_Injury_free_rate+=Defense_value[m];
else if(bag_Equipped[_cursor] == 1)
my_Injury_free_rate-=Defense_value[m];
}
if(bag_Equipped[_cursor] == 0)
{
bag_Equipped[_cursor] = 1;
gotoxy(81,cursor_y);
printf("已装备");
}
else if(bag_Equipped[_cursor] == 1)
{
bag_Equipped[_cursor] = 0;
gotoxy(81,cursor_y);
printf("未装备");
}
break;
case Backspace:
l=0;
_cursor = 2;
_cursor = cursor_y-_cursor;
s=cursor_y-2;
if(s == bag_traversal()-1)
{
cursor_y--;
}
for(int i=0;i<weapon_len;i++)
{
if(all_weapon[i] == bag_name[_cursor])
{
l=1;
m=i;
money += all_weapon_price[m]/2;
break;
}
}
for(int i=0;i<armor_len;i++)
{
if(all_aromr[i] == bag_name[_cursor])
{
l=0;
m=i;
money += Armor_price[m]/2;
break;
}
}
if(bag_Equipped[s] == 1)
{
if(l==1)
{
my_hurt=my_hurt-Injury_value[m];
}
if(l==0)
{
my_Injury_free_rate=my_Injury_free_rate-Defense_value[m];
}
}
for(int i=s;i<bag_traversal()+1;i++)
{
bag_name[i] = bag_name[i+1];
bag_price[i] = bag_price[i+1];
bag_attribute[i] = bag_attribute[i+1];
bag_Equipped[i] = bag_Equipped[i+1];
gotoxy(0,i+2);
cout<<" "<<bag_name[i]<<" ";
gotoxy(21,i+2);
cout<<bag_price[i];
gotoxy(39,i+2);
cout<<bag_attribute[i];
gotoxy(59,i+2);
cout<<bag_price[i]/2;
gotoxy(80,i+2);
if(bag_Equipped[i] == 0)cout<<"[未装备]";
else cout<<"[已装备]";
cout<<endl;
}
gotoxy(0,bag_traversal()+2);
printf(" ");
break;
case tab:
case esc:
break;
}
if(d == tab || d == esc)
{
break;
}
}
}
int Is_the_weapon_repeated(int n)
{
string a;
int count=0;
a=bag_name[n];
for(int j=0;j<bag_traversal()-1;j++)
{
if(a==bag_name[j])
{
count++;
}
}
return count;
}
int Output_or_not(int a)
{
string n = bag_name[a],c;
bool x=0;
for(int i=a;i>0;i--)
{
c=bag_name[i];
if(n == c)
{
x=1;
break;
}
}
return x;//0->没有重复1->有重复
}
void home()
{
system("cls");
switch(last_c)
{
case up:
Player_y++;
break;
case down:
Player_y--;
break;
case left:
Player_x++;
break;
case right:
Player_x--;
break;
}
go(0,0);
printf(" 睡觉 \n");
printf("按【Enter】睡觉补充100体力值和10生命值\n");
while(1)
{
int c = getch();
if(c == enter)
{
if(frequency[Checkpoint] == 0)
{
gotoxy(0,2);
cout<<"每一关只能睡觉五次哦 ";
getch();
goto b;
}
frequency[Checkpoint]--;
if(blood == blood_top && my_physical_strength == my_physical_strength_top)
{
printf("体力值与生命值已满,无需补充");
while(1)
{
c=getch();
if(c == esc)goto b;
else break;
}
break;
}
gotoxy(0,2);
cout<<" ";
gotoxy(0,2);
for(int i=0;i<10;i++)
{
Sleep(200);
printf(".");
}
gotoxy(0,2);
printf("体力值+100,生命值+10");
blood+=10;
my_physical_strength+=100;
if(blood > blood_top)
{
blood = blood_top;
}
if(my_physical_strength > my_physical_strength_top)
{
my_physical_strength = my_physical_strength_top;
}
}
else if(c == esc)
{
b:
break;
}
}
system("cls");
zy_print();
go(5,2);
printf("床");
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
}
void zy_print()
{
print_map(10,10,WALL_VIEW,0);
go(5,2);
printf("床");
go(7,7);
set_console_color(13);
printf("■");
set_console_color(15);
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
}
int bag_traversal()
{
int a;
for(int i=0;i<100;i++)
{
if(bag_price[i] == 0)
{
a=i;
break;
}
}
return a;
}
void set_console_color(unsigned short color_index)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color_index);
}
void player_moveont(int x,int y,int n)
{
int c = getch();
switch(c)
{
case up:
if(Player_y-1 != 0)
{
go(Player_x,Player_y);
printf(" ");
Player_y--;
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
}
break;
case down:
if(Player_y+1 != y-1)
{
go(Player_x,Player_y);
printf(" ");
Player_y++;
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
}
break;
case left:
if(Player_x-1 != 0)
{
go(Player_x,Player_y);
printf(" ");
Player_x--;
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
}
break;
case right:
if(Player_x+1 != x-1)
{
go(Player_x,Player_y);
printf(" ");
Player_x++;
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
}
break;
case tab:
system("cls");
print_bag();
switch(n)
{
case 1:
system("cls");
print_map(10,10,WALL_VIEW,0);
go(5,2);
printf("床");
go(7,7);
set_console_color(13);
printf("■");
set_console_color(15);
go(6,4);
printf("");
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
go(5,2);
printf("床");
break;
case 2:
system("cls");
print_map(10,10,WALL_VIEW,0);
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
go(3,2);
printf("武");
go(6,2);
printf("防");
go(6,7);
set_console_color(13);
printf("■");
set_console_color(15);
break;
case 3:
system("cls");
print_map(Map_width,Map_lenght,WALL_VIEW,0);
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
gotoxy(16,15);
printf("村庄边境");
gotoxy(44,1);
cout<<"职业:"<<my_whole_name<<endl;
gotoxy(44,2);
cout<<"血量:"<<blood<<endl;
gotoxy(44,3);
cout<<"血量上限:"<<blood_top<<endl;
gotoxy(44,4);
cout<<"体力值:"<<my_physical_strength<<endl;
gotoxy(44,5);
cout<<"体力值上限:"<<my_physical_strength_top<<endl;
gotoxy(44,6);
cout<<"伤害值:"<<my_hurt<<endl;
gotoxy(44,8);
cout<<"闪避率:"<<my_evade<<"%"<<endl;
gotoxy(44,9);
cout<<"暴击率:"<<my_hit_rate<<"%"<<endl;
gotoxy(44,10);
cout<<"免伤率:"<<my_Injury_free_rate<<"%"<<endl;
gotoxy(44,12);
cout<<"宝石:"<<money<<endl;
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
go(7,7);
set_console_color(13);
printf("■");
set_console_color(15);
break;
}
break;
}
Sleep(speed);
last_c=c;
}
void zy_animation()//【家】动画
{
system("cls");
int zy_map[5][7] =
{
{16,18,20,1,3,5,7},
{14,0,0,0,0,0,9},
{12,0,0,0,0,0,11},
{10,0,0,0,0,0,13},
{8,6,4,2,19,17,15},
};
int count=1;
for(int n=0;n<20;n++)
{
for(int i=0;i<5;i++)
{
for(int j=0;j<7;j++)
{
if(zy_map[i][j] == count)
{
go(j,i);
printf(WALL_VIEW);
Sleep(100);
}
if(count > 20)
break;
}
}
count++;
}
go(3,2);
printf("家");
go(0,9);
}
void CaiDan()
{
int x=1;
printf("■■■■■■■ ■■■■■■■ ■■■■■■■\n");
printf("■ 新游戏 ■ ■ 继续游戏 ■ ■ 设置 ■\n");
printf("■■■■■■■ ■■■■■■■ ■■■■■■■\n");
while(1)
{
switch(x)
{
case 1:
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED);
gotoxy(0,0);
printf("■■■■■■■");
gotoxy(0,1);
printf("■");
gotoxy(12,1);
printf("■");
gotoxy(0,2);
printf("■■■■■■■");
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
break;
case 2:
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED);
gotoxy(18,0);
printf("■■■■■■■");
gotoxy(18,1);
printf("■");
gotoxy(30,1);
printf("■");
gotoxy(18,2);
printf("■■■■■■■");
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
break;
case 3:
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED);
gotoxy(36,0);
printf("■■■■■■■");
gotoxy(36,1);
printf("■");
gotoxy(48,1);
printf("■");
gotoxy(36,2);
printf("■■■■■■■");
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
break;
}
int c = getch();
switch(c)
{
case right:
x++;
if(x == 4)
{
x=1;
}
break;
case left:
x--;
if(x == 0)
{
x=3;
}
break;
}
if(c == enter)
{
break;
}
switch(x)
{
case 1:
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
gotoxy(18,0);
printf("■■■■■■■");
gotoxy(18,1);
printf("■");
gotoxy(30,1);
printf("■");
gotoxy(18,2);
printf("■■■■■■■");
gotoxy(36,0);
printf("■■■■■■■");
gotoxy(36,1);
printf("■");
gotoxy(48,1);
printf("■");
gotoxy(36,2);
printf("■■■■■■■");
break;
case 2:
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
gotoxy(0,0);
printf("■■■■■■■");
gotoxy(0,1);
printf("■");
gotoxy(12,1);
printf("■");
gotoxy(0,2);
printf("■■■■■■■");
gotoxy(36,0);
printf("■■■■■■■");
gotoxy(36,1);
printf("■");
gotoxy(48,1);
printf("■");
gotoxy(36,2);
printf("■■■■■■■");
break;
case 3:
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
gotoxy(0,0);
printf("■■■■■■■");
gotoxy(0,1);
printf("■");
gotoxy(12,1);
printf("■");
gotoxy(0,2);
printf("■■■■■■■");
gotoxy(18,0);
printf("■■■■■■■");
gotoxy(18,1);
printf("■");
gotoxy(30,1);
printf("■");
gotoxy(18,2);
printf("■■■■■■■");
break;
}
}
}
void yx_animation()//【游戏】动画
{
system("cls");
int zy_map[6][6] =
{
{0,14,0,0,13,0},
{12,0,0,0,0,11},
{0,10,0,0,9,0},
{8,0,0,0,0,7},
{6,0,2,1,0,5},
{0,4,0,0,3,0},
};
int count=1;
for(int n=0;n<20;n++)
{
for(int i=0;i<6;i++)
{
for(int j=0;j<6;j++)
{
if(zy_map[i][j] == count)
{
go(j,i);
printf(WALL_VIEW);
Sleep(100);
}
if(count > 14)
break;
}
}
count++;
}
go(2,3);
printf("电竞");
go(0,9);
}
void case_player(int a)
{
switch(a)
{
case up:
Player_y++;
break;
case down:
Player_y--;
break;
case left:
Player_x++;
break;
case right:
Player_x--;
break;
}
}
void sd_animation()//【商店】动画
{
system("cls");
int zy_map[8][8] =
{
{0,0,0,16,1,0,0,0},
{0,0,14,0,0,3,0,0},
{0,12,0,0,0,0,5,0},
{10,0,0,0,0,0,0,7},
{8,0,0,0,0,0,0,9},
{0,6,0,0,0,0,11,0},
{0,0,4,0,0,13,0,0},
{0,0,0,2,15,0,0,0},
};
int count=1;
for(int n=0;n<16;n++)
{
for(int i=0;i<8;i++)
{
for(int j=0;j<8;j++)
{
if(zy_map[i][j] == count)
{
go(j,i);
printf(WALL_VIEW);
Sleep(100);
}
if(count > 16)
break;
}
}
count++;
}
go(3,3);
printf("商店");
go(0,9);
}
int GetAmount()
{
printf("您要压多少宝石,最少10个,最多100个\n");
scanf("%d",&BetMoney);
if(BetMoney<10)
{
BetMoney=10;
}
if(BetMoney>100)
{
BetMoney=100;
}
return BetMoney;
}
void Throw()
{
printf("欢迎您体验赌博机,按任意键掷色子\n");
getch();
while(!kbhit())
{
a=rand()%6+1;
b=rand()%6+1;
cd=rand()%6+1;
system("cls");
printf("色子在转动:...............按任意键终止转动!\n");
printf("第一粒色子:%d\n第二粒色子:%d\n第三粒色子:%d\n",a,b,cd);
}
}
int Judge(int a,int b,int cd)
{
if(a==b&&a==cd)
{
return 3;
}
if(a+b+cd>11)
{
return 1;
}
else
{
if(a+b+cd<11)
{
return 2;
}
else
{
return 0;
}
}
if(Judge(a,b,cd)==3)
printf("豹子\n");
else if(Judge(a,b,cd)==1)
printf("大\n");
else if(Judge(a,b,cd)==2)
printf("小\n");
else
printf("平局\n");
}
void MoneyCalc()
{
char ch;
int judge();
if(Judge(a,b,cd)==3)
{
if(BetType==3)
{
BetMoney=BetMoney*10;
money+=BetMoney;
DealerMoney-=BetMoney;
printf("豹子,赔率10倍,您赢了庄家%d宝石,您现有%d宝石,庄家现有%d宝石\n\n",BetMoney,money,DealerMoney);
}
else
{
BetMoney=BetMoney*10;
money=BetMoney;
DealerMoney+=BetMoney;
printf("豹子,赔率10倍,您输给庄家%d宝石,你现有宝石数%d\n",BetMoney,money);
}
}
else if(Judge(a,b,cd)==1)
{
if(BetType==1)
{
BetMoney=BetMoney*2;
money+=BetMoney;
DealerMoney-=BetMoney;
printf("大,赔率2倍,您赢了庄家%d宝石,您现有宝石%d,庄家现有宝石数%d\n\n",BetMoney,money,DealerMoney);
}
else
{
BetMoney=BetMoney*2;
money-=BetMoney;
DealerMoney+=BetMoney;
printf("大,赔率2倍,您输了庄家%d宝石,您现有宝石数%d,庄家现有宝石数%d\n\n",BetMoney,money,DealerMoney);
}
}
else if(Judge(a,b,cd)==2)
{
if(BetType==2)
{
BetMoney=BetMoney*2;
money+=BetMoney;
DealerMoney-=BetMoney;
printf("小,赔率2倍,您赢了庄家%d宝石,您现有宝石数%d,庄家现有宝石数%d\n\n",BetMoney,money,DealerMoney);
}
else
{
BetMoney=BetMoney*2;
money-=BetMoney;
DealerMoney+=BetMoney;
printf("大,赔率2倍,您输了庄家%d宝石,您现有宝石数%d,庄家现有宝石数%d\n\n",BetMoney,money,DealerMoney);
}
}
else
printf("平局,您和庄家打成平手,您现有宝石数%d,庄家现有宝石数%d\n\n",money,DealerMoney);
}
void tuichu()
{
char ch;
getch();
}
void gs_print()
{
}
void gs()
{
system("cls");
int x=0;
for(int i=0;i<4;i++)
{
if(m[Checkpoint][i].shengming <= 0)
x++;
}
if(x == 4)
{
blood_top+=blood_plus[Checkpoint];
money+=money_plus[Checkpoint];
Checkpoint++;
}
print_map(Map_width,Map_lenght,WALL_VIEW,0);
gotoxy(16,15);
printf("村庄边境");
gotoxy(44,1);
cout<<"职业:"<<my_whole_name<<endl;
gotoxy(44,2);
cout<<"血量:"<<blood<<endl;
gotoxy(44,3);
cout<<"血量上限:"<<blood_top<<endl;
gotoxy(44,4);
cout<<"体力值:"<<my_physical_strength<<endl;
gotoxy(44,5);
cout<<"体力值上限:"<<my_physical_strength_top<<endl;
gotoxy(44,6);
cout<<"伤害值:"<<my_hurt<<endl;
gotoxy(44,8);
cout<<"闪避率:"<<my_evade<<"%"<<endl;
gotoxy(44,9);
cout<<"暴击率:"<<my_hit_rate<<"%"<<endl;
gotoxy(44,10);
cout<<"免伤率:"<<my_Injury_free_rate<<"%"<<endl;
gotoxy(44,12);
cout<<"宝石:"<<money<<endl;
go(7,7);
set_console_color(13);
printf("■");
set_console_color(15);
Player_x=7,Player_y=7;
switch(::c)
{
case up:
Player_y--;
break;
case down:
Player_y++;
break;
case left:
Player_x--;
break;
case right:
Player_x++;
break;
}
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
while(1)
{
for(int i=0;i<4;i++)
{
if(m[Checkpoint][i].shengming <= 0)
{
m[Checkpoint][i].x=0;
m[Checkpoint][i].y=0;
}
}
gs_print();
gs_inspect();
print_moster(false);
gs_inspect();
player_moveont(Map_lenght,Map_width,3);
gs_inspect();
}
}
void gs_inspect()
{
if(Player_x == 7 && Player_y == 7)
{
Player_x = 16;
Player_y = 12;
switch(last_c)
{
case up:
Player_y--;
break;
case down:
Player_y++;
break;
case left:
Player_x--;
break;
case right:
Player_x++;
break;
}
back_to_zy();
}
for(int i=0;i<4;i++)
{
if(Player_x == m[Checkpoint][i].x && Player_y == m[Checkpoint][i].y)
{
j_moster(Checkpoint,i);
system("cls");
print_map(Map_width,Map_lenght,WALL_VIEW,0);
gotoxy(16,15);
printf("村庄边境");
gotoxy(44,1);
cout<<"职业:"<<my_whole_name<<endl;
gotoxy(44,2);
cout<<"血量:"<<blood<<endl;
gotoxy(44,3);
cout<<"血量上限:"<<blood_top<<endl;
gotoxy(44,4);
cout<<"体力值:"<<my_physical_strength<<endl;
gotoxy(44,5);
cout<<"体力值上限:"<<my_physical_strength_top<<endl;
gotoxy(44,6);
cout<<"伤害值:"<<my_hurt<<endl;
gotoxy(44,8);
cout<<"闪避率:"<<my_evade<<"%"<<endl;
gotoxy(44,9);
cout<<"暴击率:"<<my_hit_rate<<"%"<<endl;
gotoxy(44,10);
cout<<"免伤率:"<<my_Injury_free_rate<<"%"<<endl;
gotoxy(44,12);
cout<<"宝石:"<<money<<endl;
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
go(7,7);
set_console_color(13);
printf("■");
set_console_color(15);
while(1)
{
for(int i=0;i<4;i++)
{
if(m[Checkpoint][i].shengming <= 0)
{
m[Checkpoint][i].x=0;
m[Checkpoint][i].y=0;
}
}
gs_inspect();
print_moster(false);
gs_inspect();
player_moveont(Map_lenght,Map_width,3);
gs_inspect();
}
}
}
}
void play()
{
char ch;
int shu1;
int shu2;
printf("欢迎体验赌博机9.0\n");
printf("下面介绍规则\n");
printf("*******************************************************************************\n");
printf("闲家和庄家各有1000宝石作为起始资金\n");
printf("在赌博机9.0中闲家及玩家,庄家就是赌场老板\n");
printf("闲家可以选择下注防暑以及所下的宝石数(宝石数不小于10,不大于100)\n");
printf("闲家可以选择下注方式有三种买大,买小,买豹子,假如三粒色的和大于11点则买大赢,小于11点则小,11点平,豹子必须三粒色字一样\n");
printf("买大,买小的赔率为2,买豹子号赔率为10\n");
printf("过程中闲家可以按下q键终止游戏,则直到有一方输光为止\n");
printf("规则说完了,祝您玩得愉快\n");
while(1)
{
shu1=money;
shu2=DealerMoney;
if(shu1<10)
{
printf("您没有足够的宝石进行下注,被赶出赌场!\n");
break;
}
if(shu2<10)
{
printf("庄家没有足够的宝石下堵住了,游戏结束,下次再来。\n");
break;
}
printf("请选择下注方式:\n");
printf("1.买大2.买小3.买豹子\n");
printf("请下注\n");
scanf("%d",&BetType);
loop:
printf("您要压多少宝石,最少10个,最多100个\n");
scanf("%d",&BetMoney);
if(BetMoney<10)
{
BetMoney=10;
}
if(BetMoney>100)
{
BetMoney=100;
}
if(BetMoney>shu1)
{
printf("您没有足够的宝石,请重新下注!\n");
goto loop;
}
Throw();
MoneyCalc();
getch();
printf("退出请按q\n");
ch=getch();
if(ch=='q')
{
break;
}
}
}
void GetTime()
{
time_t rawtime;
struct tm*timeinfo;
time(&rawtime);
timeinfo=localtime(&rawtime);
time_t tick=mktime(timeinfo);
Year=timeinfo->tm_year+1900;
Mon=timeinfo->tm_mon+1;
Day=timeinfo->tm_mday;
Hour=timeinfo->tm_hour;
Min=timeinfo->tm_min;
Sec=timeinfo->tm_sec;
WDay=timeinfo->tm_wday;
}
void print_moster(bool l)
{
int direction_x[] = {0,-1,0,1,0},direction_y[] = {0,0,-1,0,1},a;
for(int i=0;i<4;i++)
{
label:
if(m[Checkpoint][i].shengming <= 0)
{
m[Checkpoint][i].x=0;
m[Checkpoint][i].y=0;
}
if(m[Checkpoint][i].x!=0 && m[Checkpoint][i].y!=0)
{
if(m[Checkpoint][i].x != Player_x && m[Checkpoint][i].y != Player_y)
a=rand()%5;
else
a=rand()%4+1;
go(m[Checkpoint][i].x,m[Checkpoint][i].y);
cout<<" ";
m[Checkpoint][i].x=m[Checkpoint][i].x+direction_x[a];
m[Checkpoint][i].y=m[Checkpoint][i].y+direction_y[a];
if(m[Checkpoint][i].x == Map_lenght-1 || m[Checkpoint][i].x == 0 || (m[Checkpoint][i].x == 7 && m[Checkpoint][i].y == 7) || m[Checkpoint][i].y == Map_width-1 || m[Checkpoint][i].y == 0 || find_if_monster(Checkpoint,i) == false || (m[Checkpoint][i].x == Player_x && m[Checkpoint][i].y == Player_y && l))
{
m[Checkpoint][i].x=m[Checkpoint][i].x-direction_x[a];
m[Checkpoint][i].y=m[Checkpoint][i].y-direction_y[a];
goto label;
}
go(m[Checkpoint][i].x,m[Checkpoint][i].y);
cout<<m[Checkpoint][i].name;
}
}
}
int find_if_monster(int a,int b)//a->怪物的关卡 b->当前怪物
{
int count=0;
for(int i=0;i<4;i++)
{
if(m[a][i].x == m[a][b].x && m[a][i].y == m[a][b].y)
count++;
}
if(count >= 2)return false;
else return true;
}
void j_moster(int a,int b)
{
int Player_baoji,Player_mianshang,Player_shanbi;
int monster_baoji,monster_mianshang,monster_shanbi;
l:
system("cls");
int baoshi=100;
gotoxy(22,0);
cout<<"怪物信息:";
gotoxy(20,2);
cout<<"名称:"<<m[a][b].all_name;
gotoxy(20,3);
cout<<"生命值:"<<m[a][b].shengming;
gotoxy(20,4);
cout<<"体力值:无";
gotoxy(20,5);
cout<<"伤害值:"<<m[a][b].shanghai;
gotoxy(20,6);
cout<<"免伤率:"<<m[a][b].mianshang;
gotoxy(20,7);
cout<<"暴击率:"<<m[a][b].baoji;
gotoxy(20,8);
cout<<"闪避率:"<<m[a][b].shanbi;
gotoxy(20,9);
cout<<"掉落宝石:"<<m[a][b].drop;
gotoxy(5,2);
cout<<"攻击";
gotoxy(5,4);
cout<<"逃跑(-10体力)";
cursor_x=2;
cursor_y=2;
_cursor;
int c;
while(1)
{
gotoxy(cursor_x,cursor_y);
printf(cursor);
gotoxy(5,cursor_y);
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED);
if(cursor_y == 2)
cout<<"攻击";
if(cursor_y == 4)
cout<<"逃跑(-10体力)";
SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
c=getch();
switch(c)
{
case up:
gotoxy(5,cursor_y);
if(cursor_y == 2)
cout<<"攻击";
if(cursor_y == 4)
cout<<"逃跑(-10体力)";
gotoxy(cursor_x,cursor_y);
printf(" ");
cursor_y+=2;
if(cursor_y >= 4)
cursor_y=2;
break;
case down:
gotoxy(5,cursor_y);
if(cursor_y == 2)
cout<<"攻击";
if(cursor_y == 4)
cout<<"逃跑(-10体力)";
gotoxy(cursor_x,cursor_y);
printf(" ");
cursor_y-=2;
if(cursor_y <= 2)
cursor_y=4;
break;
case enter:
_cursor = cursor_y/2;
break;
}
if(c == enter)break;
}
if(_cursor == 2)
{
my_physical_strength-=10;
if(my_physical_strength < 0)
physical_strength_died();
case_player(last_c);
system("cls");
print_map(Map_width,Map_lenght,WALL_VIEW,0);
gotoxy(16,15);
printf("村庄边境");
gotoxy(44,1);
cout<<"职业:"<<my_whole_name<<endl;
gotoxy(44,2);
cout<<"血量:"<<blood<<endl;
gotoxy(44,3);
cout<<"血量上限:"<<blood_top<<endl;
gotoxy(44,4);
cout<<"体力值:"<<my_physical_strength<<endl;
gotoxy(44,5);
cout<<"体力值上限:"<<my_physical_strength_top<<endl;
gotoxy(44,6);
cout<<"伤害值:"<<my_hurt<<endl;
gotoxy(44,8);
cout<<"闪避率:"<<my_evade<<"%"<<endl;
gotoxy(44,9);
cout<<"暴击率:"<<my_hit_rate<<"%"<<endl;
gotoxy(44,10);
cout<<"免伤率:"<<my_Injury_free_rate<<"%"<<endl;
gotoxy(44,12);
cout<<"宝石:"<<money<<endl;
go(Player_x,Player_y);
set_console_color(243);
cout<<my_name;
set_console_color(15);
go(7,7);
set_console_color(13);
printf("■");
set_console_color(15);
print_moster(true);
while(1)
{
for(int i=0;i<4;i++)
{
if(m[Checkpoint][i].shengming <= 0)
{
m[Checkpoint][i].x=0;
m[Checkpoint][i].y=0;
}
}
gs_print();
gs_inspect();
print_moster(false);
gs_inspect();
player_moveont(Map_lenght,Map_width,3);
gs_inspect();
}
}
cursor_x=12;
cursor_y=11;
while(1)
{
system("cls");
gotoxy(7,0);
cout<<"玩家信息:";
gotoxy(5,2);
cout<<"职业:"<<my_whole_name;
gotoxy(5,3);
cout<<"生命值:"<<blood;
gotoxy(5,4);
cout<<"体力值:"<<my_physical_strength<<" ";
gotoxy(5,5);
cout<<"伤害值:"<<my_hurt;
gotoxy(5,7);
cout<<"闪避率:"<<my_evade<<"%";
gotoxy(5,8);
cout<<"暴击率:"<<my_hit_rate<<"%";
gotoxy(5,9);
cout<<"免伤率:"<<my_Injury_free_rate<<"%";
gotoxy(19,2);
cout<<"VS";
gotoxy(26,0);
cout<<"怪物信息:";
gotoxy(24,2);
cout<<"名称:"<<m[a][b].all_name;
gotoxy(24,3);
cout<<"生命值:"<<m[a][b].shengming;
gotoxy(24,4);
cout<<"体力值:无";
gotoxy(24,5);
cout<<"伤害值:"<<m[a][b].shanghai;
gotoxy(24,6);
cout<<"免伤率:"<<m[a][b].mianshang;
gotoxy(24,7);
cout<<"暴击率:"<<m[a][b].baoji;
gotoxy(24,8);
cout<<"闪避率:"<<m[a][b].shanbi;
gotoxy(24,9);
cout<<"掉落宝石:"<<m[a][b].drop;
gotoxy(15,11);
printf("普通攻击(伤害值%d,消耗体力值10)",my_hurt/2);
gotoxy(15,12);
printf("强化攻击(伤害值%d,消耗体力值20)",my_hurt);
gotoxy(15,13);
printf("附魔攻击(伤害值%d,消耗体力值30)",my_hurt*2);
_cursor=10;
while(1)
{
gotoxy(cursor_x,cursor_y);
cout<<cursor;
c=getch();
switch(c)
{
case up:
gotoxy(cursor_x,cursor_y);
cout<<" ";
if(cursor_y-1 >= 11)
cursor_y--;
else
cursor_y=13;
break;
case down:
gotoxy(cursor_x,cursor_y);
cout<<" ";
if(cursor_y+1 <= 13)
cursor_y++;
else
cursor_y=11;
break;
case enter:
_cursor = cursor_y - _cursor;
break;
case esc:
break;
}
if(c == esc || c == enter)
break;
}
if(c == esc)
{
goto l;
}
int hurt;
switch(_cursor)
{
case 1:
hurt=my_hurt/2;
my_physical_strength-=10;
break;
case 2:
hurt=my_hurt;
my_physical_strength-=20;
break;
case 3:
hurt=my_hurt*2;
my_physical_strength-=30;
break;
}
Player_baoji=rand()%100+1,Player_shanbi=rand()%100+1;
monster_baoji=rand()%100+1,monster_shanbi=rand()%100+1;
if(Player_baoji < my_hit_rate)
{
gotoxy(3,1);
cout<<"[暴击]";
hurt=my_hurt*2;
}
if(Player_shanbi < my_evade)
{
gotoxy(11,1);
cout<<"[闪避]";
blood+=m[a][b].shanghai*1.0*((100-my_Injury_free_rate)*0.01);
if(monster_baoji < m[a][b].baoji)
{
blood+=m[a][b].shanghai*1.5;
}
}
if(monster_baoji < m[a][b].baoji)
{
gotoxy(24,1);
cout<<"[暴击]";
blood+=m[a][b].shanghai*1.0*((100-my_Injury_free_rate)*0.01);
blood-=m[a][b].shanghai*1.5;
}
if(monster_shanbi < m[a][b].shanbi)
{
gotoxy(32,1);
cout<<"[闪避]";
if(Player_baoji < my_hit_rate)
hurt=my_hurt/2;
m[a][b].shengming+=hurt*1.0*((100-m[a][b].mianshang)*0.01);
}
blood-=m[a][b].shanghai*1.0*((100-my_Injury_free_rate)*0.01);
m[a][b].shengming-=hurt*1.0*((100-m[a][b].mianshang)*0.01);
if(blood <= 0)
{
for(int i=0;i<bag_traversal();i++)
{
if(bag_name[i] == "复活甲" && bag_Equipped[i] == 1)
{
blood=blood_top;
gotoxy(6,10);
set_console_color(19);
cout<<"原地复活";
set_console_color(15);
for(int j=i;j<bag_traversal()+1;j++)
{
bag_name[i] = bag_name[i+1];
bag_price[i] = bag_price[i+1];
bag_attribute[i] = bag_attribute[i+1];
bag_Equipped[i] = bag_Equipped[i+1];
}
for(int j=i;i<bag_traversal()+1;i++)
{
bag_name[i] = bag_name[i+1];
bag_price[i] = bag_price[i+1];
bag_attribute[i] = bag_attribute[i+1];
bag_Equipped[i] = bag_Equipped[i+1];
}
sleep(1);
}
}
}
Sleep(500);
if(my_physical_strength <= 0)
physical_strength_died();
if(blood <= 0)
blood_died();
if(0 >= m[a][b].shengming)
{
system("cls");
xlc_monster[a] = 1;
gotoxy(20,5);
printf("怪物被击败了,获得%d宝石",m[a][b].drop);
money+=m[a][b].drop;
int flag=1;
for(int i=0;i<4;i++)
{
if(m[5][i].shengming >= 0){
flag=0;
}
}
if(flag)
{
Victory_interface();
}
sleep(2);
break;
}
}
}
void start()
{
getch();
set_console_color(130);
int map[9][25] =
{
{85,0 ,0 ,0 ,94 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 },
{86,0 ,0 ,95,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 },
{87,0 ,96,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,124,0 ,0 ,0 ,0 ,0 ,0 },
{88,97,0 ,0 ,0 ,0 ,0 ,104,105,0 ,0 ,111,0 ,0 ,0 ,0 ,0 ,125,0 ,0 ,0 ,0 ,136,0 },
{89,0 ,98,0 ,0 ,0 ,103,0 ,0 ,106,0 ,0 ,0 ,116,117,118,0 ,126,129,130,0 ,133,134,135},
{90,0 ,0 ,99,0 ,0 ,102,0 ,0 ,107,0 ,110,0 ,115,0 ,119,0 ,127,0 ,131,0 ,0 ,137,0 },
{91,0 ,0 ,0 ,100,0 ,101,0 ,0 ,108,0 ,109,0 ,114,113,112,0 ,128,0 ,132,0 ,0 ,138,139},
{0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,120,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 },
{0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,123,122,121,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 },
};
for(int k=0;k<200;k++)
{
for(int i=0;i<9;i++)
{
for(int j=0;j<25;j++)
{
if(k == 1)
set_console_color(135);
if(map[i][j] == k)
{
go(j+10,i+8);
cout<<WALL_VIEW;
Sleep(5);
}
}
}
}
go(10,17);
cout<<"请确保您的输出法已调成英文模式.........";
go(10,18);
system("pause");
set_console_color(15);
system("cls");
}
void Victory_interface()
{
system("cls");
int y[6][5] =
{
{1 , 0 , 0 , 0 , 3},
{0 , 2 , 0 , 4 , 0},
{0 , 0 , 5 , 0 , 0},
{0 , 0 , 6 , 0 , 0},
{0 , 0 , 7 , 0 , 0},
{0 , 0 , 8 , 0 , 0},
};
int o[6][5] =
{
{0 , 3 , 4 , 5 , 0},
{2 , 0 , 0 , 0 , 6},
{1 , 0 , 0 , 0 , 7},
{14, 0 , 0 , 0 , 8},
{13, 0 , 0 , 0 , 9},
{0 , 12, 11, 10, 0},
};
int u[6][5] =
{
{1 , 0 , 0 , 0 ,13},
{2 , 0 , 0 , 0 ,12},
{3 , 0 , 0 , 0 ,11},
{4 , 0 , 0 , 0 ,10},
{5 , 0 , 0 , 0 , 9},
{0 , 6 , 7 , 8 , 0},
};
int a[6][5] =
{
{0 , 3 , 2 , 1 ,0},
{4 , 0 , 0 , 0 ,14},
{5 , 0 , 0 , 0 ,13},
{6 , 0 , 0 , 0 ,12},
{7 , 0 , 0 , 0 ,11},
{0 , 8 , 9 , 10,16},
};
int r[6][5] =
{
{1 , 0 , 0 , 0 , 0},
{0 , 2 , 7 , 8 , 9},
{0 , 3 , 0 , 0 , 0},
{0 , 4 , 0 , 0 , 0},
{0 , 5 , 0 , 0 , 0},
{0 , 6 , 0 , 0 , 0},
};
int e[6][5] =
{
{0 , 0 , 0 , 0 , 0},
{7 , 6 , 5 , 4 , 0},
{8 , 0 , 0 , 0 , 3},
{9 , 0 , 1 , 2 , 0},
{10, 0 , 0 , 0 , 0},
{0 , 11, 12, 13,14},
};
int w[6][5] =
{
{1 , 0 , 0 , 0 ,15},
{2 , 0 , 0 , 0 ,14},
{3 , 0 , 9 , 0 ,13},
{4 , 0 , 8 , 0 ,12},
{5 , 0 , 7 , 0 ,11},
{0 , 6 , 0 , 10, 0},
};
int i_[6][5] =
{
{0 , 0 , 5 , 0 , 0},
{0 , 0 , 0 , 0 , 0},
{0 , 0 , 1 , 0 , 0},
{0 , 0 , 2 , 0 , 0},
{0 , 0 , 3 , 0 , 0},
{0 , 0 , 4 , 0 , 0},
};
int n[6][5] =
{
{0 , 6 , 7 , 8 , 0},
{5 , 0 , 0 , 0 , 9},
{4 , 0 , 0 , 0 ,10},
{3 , 0 , 0 , 0 ,11},
{2 , 0 , 0 , 0 ,12},
{1 , 0 , 0 , 0 ,13},
};
int count=1;
for(int n=0;n<20;n++)
{
for(int i=0;i<6;i++)
{
for(int j=0;j<5;j++)
{
if(y[i][j] == count)
{
go(j,i);
printf(WALL_VIEW);
Sleep(100);
}
if(count > 20)
break;
}
}
count++;
}
count=1;
for(int n=0;n<20;n++)
{
for(int i=0;i<6;i++)
{
for(int j=0;j<5;j++)
{
if(o[i][j] == count)
{
go(j+6,i);
printf(WALL_VIEW);
Sleep(100);
}
if(count > 20)
break;
}
}
count++;
}
count=1;
for(int n=0;n<20;n++)
{
for(int i=0;i<6;i++)
{
for(int j=0;j<5;j++)
{
if(u[i][j] == count)
{
go(j+12,i);
printf(WALL_VIEW);
Sleep(100);
}
if(count > 20)
break;
}
}
count++;
}
count=1;
for(int n=0;n<20;n++)
{
for(int i=0;i<6;i++)
{
for(int j=0;j<5;j++)
{
if(a[i][j] == count)
{
go(j,i+7);
printf(WALL_VIEW);
Sleep(100);
}
if(count > 20)
break;
}
}
count++;
}
count=1;
for(int n=0;n<20;n++)
{
for(int i=0;i<6;i++)
{
for(int j=0;j<5;j++)
{
if(r[i][j] == count)
{
go(j+6,i+7);
printf(WALL_VIEW);
Sleep(100);
}
if(count > 20)
break;
}
}
count++;
}
count=1;
for(int n=0;n<20;n++)
{
for(int i=0;i<6;i++)
{
for(int j=0;j<5;j++)
{
if(e[i][j] == count)
{
go(j+12,i+7);
printf(WALL_VIEW);
Sleep(100);
}
if(count > 20)
break;
}
}
count++;
}
count=1;
for(int n=0;n<20;n++)
{
for(int i=0;i<6;i++)
{
for(int j=0;j<5;j++)
{
if(w[i][j] == count)
{
go(j,i+14);
printf(WALL_VIEW);
Sleep(100);
}
if(count > 20)
break;
}
}
count++;
}
count=1;
for(int n=0;n<20;n++)
{
for(int i=0;i<6;i++)
{
for(int j=0;j<5;j++)
{
if(i_[i][j] == count)
{
go(j+6,i+14);
printf(WALL_VIEW);
Sleep(100);
}
if(count > 20)
break;
}
}
count++;
}
count=1;
for(int f=0;f<20;f++)
{
for(int i=0;i<6;i++)
{
for(int j=0;j<5;j++)
{
if(n[i][j] == count)
{
go(j+12,i+14);
printf(WALL_VIEW);
Sleep(100);
}
if(count > 20)
break;
}
}
count++;
}
system("cls");
chonglai();
}
void chonglai()
{
set_console_color(8);
cursor_x=22;
cursor_y=8;
gotoxy(27,8);
cout<<"<重新开始>";
gotoxy(27,10);
cout<<"<结束程序>";
gotoxy(16,8);
while(1)
{
gotoxy(cursor_x,cursor_y);
printf(cursor);
int c=getch();
switch(c)
{
case up:
gotoxy(cursor_x,cursor_y);
cout<<" ";
cursor_y-=2;
if(cursor_y == 6)
{
cursor_y = 10;
}
break;
case down:
gotoxy(cursor_x,cursor_y);
cout<<" ";
cursor_y+=2;
if(cursor_y == 12)
{
cursor_y = 8;
}
break;
case enter:
_cursor=(cursor_y/2)-3;
break;
}
if(c == enter)break;
}
gotoxy(22,8);
if(_cursor == 2){
exit(0);
}
for(int i=0;i<6;i++)
{
for(int j=0;j<4;j++)
{
m[i][j].all_name = mon[i][j].all_name;
m[i][j].baoji = mon[i][j].baoji;
m[i][j].drop = mon[i][j].drop;
m[i][j].mianshang = mon[i][j].mianshang;
m[i][j].name = mon[i][j].name;
m[i][j].shanbi = mon[i][j].shanbi;
m[i][j].shengming = mon[i][j].shengming;
m[i][j].shanghai = mon[i][j].shanghai;
m[i][j].x = mon[i][j].x;
m[i][j].y = mon[i][j].y;
}
}
for(int i=0;i<bag_traversal()+1;i++)
{
bag_name[i] = "";
bag_price[i] = 0;
bag_attribute[i] = "";
bag_Equipped[i] = 0;
}
system("cls");
money=2000;
set_console_color(15);
init();
Choice_of_occupation();
Draw_Map();
while(1)
{
Player_move();
inspect();
Sleep(speed);
}
}
游戏---元气骑士
最新推荐文章于 2024-08-05 22:01:02 发布