洛谷转载。。。感谢原作者(1)
2025-03-05 21:57:21
发布于:广东
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
typedef struct Frame
{
COORD position[2];
}Frame;
void Color(int a)
{
//白
if(a0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
//绿
if(a1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
//红
if(a2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
//蓝
if(a3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
//粉
if(a4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
//黄
if(a5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
//灰
if(a6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
//棕
if(a7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN);
//随机
if(a == -1) Color(rand() % 8);
}
void SetPos(COORD a)// set cursor
{
HANDLE out=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(out, a);
}
void SetPos(int i, int j)// set cursor
{
COORD pos={short(i), short(j)};
SetPos(pos);
}
void HideCursor()
{
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
char input()
{
while(1)
{
if(_kbhit())
{
return _getch();
}
}
}
char input(int i, int j)
{
while(1)
{
char x = input();
if(x >= i && x <= j) return x;
}
}
//在[a, b)之间产生一个随机整数
int random(int a, int b)
{
int c=(rand() % (a-b))+ a;
return c;
}
struct BLOCK
{
int id;
string txt;
int color;
int hard;
int level; //挖掘等级(0=徒手 1=木 2=石 3=铁 4=钻石 5=合金)
string name;
bool fluid; //是否为流体(可以穿越 能够替换成方块)
};
BLOCK block[] = //方块
{
{0, "□", 0, 2000000000, 100, "基岩", false},
{1, "■", 6, 250, 1, "石头", false},
{2, "▓ ", 7, 75, 0, "泥土", false},
{3, "▓ ", 6, 75, 0, "砂砾", false},
{4, "■", 5, 80, 0, "木头", false},
{5, "※", 0, 500, 2, "铁矿石", false},
{6, "∷", 0, 500, 2, "铁块", false},
{7, "※", 5, 600, 3, "金矿石", false},
{8, "∷", 5, 600, 3, "金块", false},
{9, "※", 3, 900, 3, "钻石矿石", false},
{10, "∷", 3, 900, 3, "钻石块", false},
{11, "▓ ", 1, 20, 0, "树叶", false},
{12, "■", 3, 2000000000, 100, "水", true},
{13, "□", 2, 2000000000, 100, "岩浆", true},
{14, "□", 0, 2000, 4, "真正的基岩", false},
{15, "■", 4, 45, 0, "地狱岩", false},
{16, "□", 4, 3000, 4, "远古残骸", false},
{17, "∷", 4, 3000, 4, "下界合金块", false},
{18, "■", 2, 2000000000, 100, "地幔", true},
{19, " ", 0, 2000000000, 100, "空气", true},
{20, "●", 4, 3000, 3, "海洋之星", false},
{21, "□", 3, 2500, 3, "海能石", false},
{22, "※", 1, 1200, 3, "绿宝石矿石", false},
{23, "∷", 1, 1200, 3, "绿宝石块", false},
{24, "■", 7, 2400, 1, "神殿方块", false},
{25, "<>", 2, 6000, 2, "神殿核心", false},
{26, "于", 2, 10000, 1, "于苗晶体A", false},
{27, "苗", 2, 10000, 1, "于苗晶体B", false},
{28, "{}", 3, 7500, 1, "宝藏锚点", false},
{29, "■", 2, 1000, 0, "TNT", false},
{30, "■", 5, 1000, 0, "TNT", false},
{31, "■", 2, 1000, 0, "TNT", false},
{32, "■", 2, 1000, 0, "TNT", false},
{33, "■", 3, 80000, 2, "地牢石", false},
{34, "※", 3, 150000, 4, "魂石", false},
{35, "▓ ", 3, 2000000000, 100, "死水", true},
{36, "■", 5, 440, 2, "下界砖", false}
};
int block_max = 36;
struct ITEM
{
int id;
int hurt;
int speed; //每个短刻的挖掘进度
int level;
string name;
int rare; //稀有度 白0<绿1<蓝2<紫3<幻4
};
ITEM item[] = //物品
{
{0, 0, 0, 0, "空气", 0},
{1, 2, 20, 1, "木镐", 0},
{2, 5, 0, 1, "木剑", 0},
{3, 3, 40, 2, "石镐", 0},
{4, 6, 0, 2, "石剑", 0},
{5, 0, 0, 0, "铁锭", 0},
{6, 4, 80, 3, "铁镐", 0},
{7, 9, 0, 3, "铁剑", 0},
{8, 0, 0, 0, "金锭", 1},
{9, 3, 30, 3, "金镐", 1},
{10, 6, 0, 3, "金剑", 1},
{11, 0, 0, 0, "钻石", 2},
{12, 5, 200, 4, "钻石镐", 2},
{13, 12, 0, 4, "钻石剑", 2},
{14, 0, 0, 0, "下界合金碎片", 3},
{15, 0, 0, 0, "下界合金锭", 3},
{16, 6, 900, 5, "下界合金镐", 3},
{17, 15, 0, 5, "下界合金剑", 3},
{18, 0, 0, 0, "桶", 0},
{19, 0, 0, 0, "水桶", 0},
{20, 0, 0, 0, "岩浆桶", 0},
{21, 0, 0, 0, "药水量子", 3},
{22, 0, 0, 0, "强化量子", 3},
{23, 0, 0, 0, "绿宝石", 2},
{24, 6, 150, 4, "绿宝石镐", 2},
{25, 11, 0, 4, "绿宝石剑", 2},
{26, 0, 100, 0, "海洋创造锤", 3},
{27, 0, 0, 0, "无尽核心", 4},
{28, 0, 0, 0, "宝藏探测器", 4},
{29, 0, 0, 0, "死水桶", 0},
{30, 0, 0, 0, "灵魂之星", 3},
{31, 6, 1600, 5, "灵魂镐", 3},
{32, 17, 0, 5, "灵魂剑", 3}
};
int item_max = 32;
struct ARMOR
{
int id;
int defease; //最高为20 可抵御(defease*4)%伤害
string name;
};
ARMOR armor[] = //盔甲
{
{0, 0, "空"},
{1, 4, "木盔甲"},
{2, 8, "石盔甲"},
{3, 12, "铁盔甲"},
{4, 16, "钻石盔甲"},
{5, 20, "下界合金盔甲"}
};
struct BUFF
{
int id;
string name;
int level; //等级 默认为0 1级以上显示在玩家属性页面中
int time; //单位: short_tick 降至0后等级降至0级
};
BUFF buff[] = //效果
{
{0, "空", 0, 0},
{1, "生命提升", 0, 0},
{2, "急迫", 0, 0},
{3, "生命吸收", 0, 0},
{4, "中毒", 0, 0}
};
const int buff_max = 4;
string buff_str[] = //效果简介
{
"空效果",
"能够提升生命值 每级提升4点生命值",
"能够加快挖掘速度 每级提升25%挖掘速度",
"获得护盾 每级提升1点免伤值",
"负面效果 每级每个构造刻受到1点伤害"
};
int gamemode = 0; //0=生存 1=创造 2=极限
int short_tick = 0, tick = 0; //短刻(每秒10次)和构造刻(每秒1次)
BLOCK world[2400][1200]; //地图 x0~2399 y0~1199
BLOCK fkl[5]; //方块栏
ITEM wpl[5]; //物品栏
ARMOR kjl = armor[0]; //盔甲栏 做出盔甲立即替换
const int xgmax = 5; //可获得的效果总数
BUFF xgl[xgmax]; //效果栏
int xgnum; //已拥有BUFF
int fknum[5], wpnum[5]; //数量(max:64)
int now = 0; //目前手持方块/物品 0~4方块 5~9物品
int playerx = 1200, playery = 700; //冒险者 坐标
double health = 20; //生命
double max_health = 20; //生命值上限
int oxygen = 20; //氧气
int energy = 0; //跳跃能量
int wjjd = 0; //挖掘进度
int zhuiluo = 0; //连续坠落格数
int level = 0, xp = 0; //等级、经验
bool tick_attack = false; //本tick是否受伤
void print_data();
void input_data();
//地牢结构
int dilao_jiegou[27][29] = {
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 3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};
void block_copy(int x, int y, int id) //将一个方块放置到某个坐标
{
world[x][y].id = id;
world[x][y].txt = block[id].txt;
world[x][y].color = block[id].color;
world[x][y].hard = block[id].hard;
world[x][y].name = block[id].name;
world[x][y].level = block[id].level;
world[x][y].fluid = block[id].fluid;
}
void chengshi(int x, int y) //下界城市的生成
{
queue<pair<pair<int, int>, int> > q;
int size = 5;
x /= 9;
y /= 9;
int nt = 1;
q.push({{x, y}, 1});
for(int i = 0;i < 9;i++)
{
for(int j = 0;j < 9;j++)
{
if(nt == 1)
{
if(nc_core[i][j] == 2)
{
block_copy(x * 9 + i, y * 9 + j, 19);
}
else if(nc_core[i][j] == 0) ;
else block_copy(x * 9 + i, y * 9 + j, 36);
}
else if(nt == 2)
{
if(nc_sp_ld[i][j] == 2)
{
block_copy(x * 9 + i, y * 9 + j, 19);
}
else if(nc_sp_ld[i][j] == 0);
else block_copy(x * 9 + i, y * 9 + j, 36);
}
else if(nt == 3)
{
if(nc_cz_ld[i][j] == 2)
{
block_copy(x * 9 + i, y * 9 + j, 19);
}
else if(nc_cz_ld[i][j] == 0) ;
else block_copy(x * 9 + i, y * 9 + j, 36);
}
}
}
nt = 2;
q.push({{x - 1, y}, 2});
for(int i = 0;i < 9;i++)
{
for(int j = 0;j < 9;j++)
{
if(nt == 1)
{
if(nc_core[i][j] == 2)
{
block_copy(x * 9 - 9 + i, y * 9 + j, 19);
}
else if(nc_core[i][j] == 0);
else block_copy(x * 9 - 9 + i, y * 9 + j, 36);
}
else if(nt == 2)
{
if(nc_sp_ld[i][j] == 2)
{
block_copy(x * 9 - 9 + i, y * 9 + j, 19);
}
else if(nc_sp_ld[i][j] == 0);
else block_copy(x * 9 - 9 + i, y * 9 + j, 36);
}
else if(nt == 3)
{
if(nc_cz_ld[i][j] == 2)
{
block_copy(x * 9 - 9 + i, y * 9 + j, 19);
}
else if(nc_cz_ld[i][j] == 0) ;
else block_copy(x * 9 - 9 + i, y * 9 + j, 36);
}
}
}
q.push({{x + 1, y}, 2});
for(int i = 0;i < 9;i++)
{
for(int j = 0;j < 9;j++)
{
if(nt == 1)
{
if(nc_core[i][j] == 2)
{
block_copy(x * 9 + 9 + i, y * 9 + j, 19);
}
else if(nc_core[i][j] == 0) ;
else block_copy(x * 9 + 9 + i, y * 9 + j, 36);
}
else if(nt == 2)
{
if(nc_sp_ld[i][j] == 2)
{
block_copy(x * 9 + 9 + i, y * 9 + j, 19);
}
else if(nc_sp_ld[i][j] == 0) ;
else block_copy(x * 9 + 9 + i, y * 9 + j, 36);
}
else if(nt == 3)
{
if(nc_cz_ld[i][j] == 2)
{
block_copy(x * 9 + 9 + i, y * 9 + j, 19);
}
else if(nc_cz_ld[i][j] == 0) ;
else block_copy(x * 9 + 9 + i, y * 9 + j, 36);
}
}
}
nt = 3;
q.push({{x, y - 1}, 3});
for(int i = 0;i < 9;i++)
{
for(int j = 0;j < 9;j++)
{
if(nt == 1)
{
if(nc_core[i][j] == 2)
{
block_copy(x * 9 + i, y * 9 - 9 + j, 19);
}
else if(nc_core[i][j] == 0) ;
else block_copy(x * 9 + i, y * 9 - 9 + j, 36);
}
else if(nt == 2)
{
if(nc_sp_ld[i][j] == 2)
{
block_copy(x * 9 + i, y * 9 - 9 + j, 19);
}
else if(nc_sp_ld[i][j] == 0) ;
else block_copy(x * 9 + i, y * 9 - 9 + j, 36);
}
else if(nt == 3)
{
if(nc_cz_ld[i][j] == 2)
{
block_copy(x * 9 + i, y * 9 - 9 + j, 19);
}
else if(nc_cz_ld[i][j] == 0) ;
else block_copy(x * 9 + i, y * 9 - 9 + j, 36);
}
}
}
q.push({{x, y + 1}, 3});
for(int i = 0;i < 9;i++)
{
for(int j = 0;j < 9;j++)
{
if(nt == 1)
{
if(nc_core[i][j] == 2)
{
block_copy(x * 9 + i, y * 9 + 9 + j, 19);
}
else if(nc_core[i][j] == 0);
else block_copy(x * 9 + i, y * 9 + 9 + j, 36);
}
else if(nt == 2)
{
if(nc_sp_ld[i][j] == 2)
{
block_copy(x * 9 + i, y * 9 + 9 + j, 19);
}
else if(nc_sp_ld[i][j] == 0) ;
else block_copy(x * 9 + i, y * 9 + 9 + j, 36);
}
else if(nt == 3)
{
if(nc_cz_ld[i][j] == 2)
{
block_copy(x * 9 + i, y * 9 + 9 + j, 19);
}
else if(nc_cz_ld[i][j] == 0) ;
else block_copy(x * 9 + i, y * 9 + 9 + j, 36);
}
}
}
while(!q.empty() && size < 24)
{
int nx = q.front().first.first;
int ny = q.front().first.second;
int nt = q.front().second;
q.pop();
if(rand() % 3 <= 1 && nt != 3)
{
q.push({{nx - 1, ny}, 2});
size++;
for(int i = 0;i < 9;i++)
{
for(int j = 0;j < 9;j++)
{
if(nt == 1)
{
if(nc_core[i][j] == 2)
{
block_copy(nx * 9 + i, ny * 9 + j, 19);
}
else if(nc_core[i][j] == 0) continue;
else block_copy(nx * 9 + i, ny * 9 + j, 36);
}
else if(nt == 2)
{
if(nc_sp_ld[i][j] == 2)
{
block_copy(nx * 9 + i, ny * 9 + j, 19);
}
else if(nc_sp_ld[i][j] == 0) continue;
else block_copy(nx * 9 + i, ny * 9 + j, 36);
}
else if(nt == 3)
{
if(nc_cz_ld[i][j] == 2)
{
block_copy(nx * 9 + i, ny * 9 + j, 19);
}
else if(nc_cz_ld[i][j] == 0) continue;
else block_copy(nx * 9 + i, ny * 9 + j, 36);
}
}
}
}
if(rand() % 3 <= 1 && nt != 3)
{
q.push({{nx + 1, ny}, 2});
size++;
for(int i = 0;i < 9;i++)
{
for(int j = 0;j < 9;j++)
{
if(nt == 1)
{
if(nc_core[i][j] == 2)
{
block_copy(nx * 9 + i, ny * 9 + j, 19);
}
else if(nc_core[i][j] == 0) continue;
else block_copy(nx * 9 + i, ny * 9 + j, 36);
}
else if(nt == 2)
{
if(nc_sp_ld[i][j] == 2)
{
block_copy(nx * 9 + i, ny * 9 + j, 19);
}
else if(nc_sp_ld[i][j] == 0) continue;
else block_copy(nx * 9 + i, ny * 9 + j, 36);
}
else if(nt == 3)
{
if(nc_cz_ld[i][j] == 2)
{
block_copy(nx * 9 + i, ny * 9 + j, 19);
}
else if(nc_cz_ld[i][j] == 0) continue;
else block_copy(nx * 9 + i, ny * 9 + j, 36);
}
}
}
}
if(rand() % 3 <= 1 && nt != 2)
{
q.push({{nx, ny - 1}, 3});
size++;
for(int i = 0;i < 9;i++)
{
for(int j = 0;j < 9;j++)
{
if(nt == 1)
{
if(nc_core[i][j] == 2)
{
block_copy(nx * 9 + i, ny * 9 + j, 19);
}
else if(nc_core[i][j] == 0) continue;
else block_copy(nx * 9 + i, ny * 9 + j, 36);
}
else if(nt == 2)
{
if(nc_sp_ld[i][j] == 2)
{
block_copy(nx * 9 + i, ny * 9 + j, 19);
}
else if(nc_sp_ld[i][j] == 0) continue;
else block_copy(nx * 9 + i, ny * 9 + j, 36);
}
else if(nt == 3)
{
if(nc_cz_ld[i][j] == 2)
{
block_copy(nx * 9 + i, ny * 9 + j, 19);
}
else if(nc_cz_ld[i][j] == 0) continue;
else block_copy(nx * 9 + i, ny * 9 + j, 36);
}
}
}
}
if(rand() % 3 <= 1 && nt != 2)
{
q.push({{nx, ny + 1}, 3});
size++;
for(int i = 0;i < 9;i++)
{
for(int j = 0;j < 9;j++)
{
if(nt == 1)
{
if(nc_core[i][j] == 2)
{
block_copy(nx * 9 + i, ny * 9 + j, 19);
}
else if(nc_core[i][j] == 0) continue;
else block_copy(nx * 9 + i, ny * 9 + j, 36);
}
else if(nt == 2)
{
if(nc_sp_ld[i][j] == 2)
{
block_copy(nx * 9 + i, ny * 9 + j, 19);
}
else if(nc_sp_ld[i][j] == 0) continue;
else block_copy(nx * 9 + i, ny * 9 + j, 36);
}
else if(nt == 3)
{
if(nc_cz_ld[i][j] == 2)
{
block_copy(nx * 9 + i, ny * 9 + j, 19);
}
else if(nc_cz_ld[i][j] == 0) continue;
else block_copy(nx * 9 + i, ny * 9 + j, 36);
}
}
}
}
if(rand() % 3 <= 1 && nt != 1)
{
q.push({{nx + random(-1, 2), ny + random(-1, 2)}, 1});
size++;
for(int i = 0;i < 9;i++)
{
for(int j = 0;j < 9;j++)
{
if(nt == 1)
{
if(nc_core[i][j] == 2)
{
block_copy(nx * 9 + i, ny * 9 + j, 19);
}
else if(nc_core[i][j] == 0) continue;
else block_copy(nx * 9 + i, ny * 9 + j, 36);
}
else if(nt == 2)
{
if(nc_sp_ld[i][j] == 2)
{
block_copy(nx * 9 + i, ny * 9 + j, 19);
}
else if(nc_sp_ld[i][j] == 0) continue;
else block_copy(nx * 9 + i, ny * 9 + j, 36);
}
else if(nt == 3)
{
if(nc_cz_ld[i][j] == 2)
{
block_copy(nx * 9 + i, ny * 9 + j, 19);
}
else if(nc_cz_ld[i][j] == 0) continue;
else block_copy(nx * 9 + i, ny * 9 + j, 36);
}
}
}
}
}
}
void init() //生成世界
{
cout << "2%" << endl;
for(int x = 0;x < 2400;x++) //填充空气
{
for(int y = 0;y < 1200;y++) block_copy(x, y, 19);
}
cout << "4%" << endl;
for(int y = 1;y < 1200;y++) //边界
{
for(int x = 0;x <= 198;x++) block_copy(x, y, 18);
for(int x = 2301;x <= 2399;x++) block_copy(x, y, 18);
block_copy(199, y, 0);
block_copy(2300, y, 0);
}
cout << "6%" << endl;
int stgd[2400]; //石头高度(海平面700)
//生成主世界构造
//确认x坐标下石头高度 (第一次构造)
stgd[1200] = 200; //默认值
for(int x = 1199;x >= 200;x--)
{
if(random(0, 1000) <= 500)
{
stgd[x] = stgd[x + 1] - random(0, 2) + random(0, 2); //小变动
}
else if(random(0, 1000) <= 100)
{
int add = random(0, 20);
add -= 10;
stgd[x] = stgd[x + 1] + add; //断崖式变动
}
else
{
stgd[x] = stgd[x + 1]; //无变动
}
if(stgd[x] > 210) stgd[x] = 210;
if(stgd[x] < 160) stgd[x] = 160;
}
cout << "12%" << endl;
for(int x = 1201;x < 2300;x++)
{
if(random(0, 1000) <= 500)
{
stgd[x] = stgd[x - 1] - random(0, 2) + random(0, 2);
}
else if(random(0, 1000) <= 100)
{
int add = random(0, 20);
add -= 10;
stgd[x] = stgd[x - 1] + add;
}
else
{
stgd[x] = stgd[x - 1];
}
if(stgd[x] > 220) stgd[x] = 220;
if(stgd[x] < 160) stgd[x] = 160;
}
cout << "15%" << endl;
//拷贝石头(主世界下边界:y=501)
for(int x = 200;x < 2300;x++)
{
for(int y = 501;y <= 501 + stgd[x];y++)
{
block_copy(x, y, 1);
//生成铁矿和金矿
if(random(1, 10000) <= 100)
{
block_copy(x, y, 5);
}
else if(random(1, 10000) <= 300)
{
block_copy(x, y, 7);
}
//生成钻石
if(y <= 515 && random(1, 10000) <= 50)
{
block_copy(x, y, 9);
}
//生成绿宝石
if(y <= 600 && random(1, 10000) <= 75)
{
block_copy(x, y, 22);
}
//生成岩浆
if(y <= 580 && random(1, 10000) <= 100)
{
block_copy(x, y, 13);
}
}
}
cout << "20%" << endl;
//增加海水(第二次构造)
for(int x = 200;x < 2300;x++)
{
for(int y = 501 + stgd[x] + 1;y <= 700;y++)
{
block_copy(x, y, 12);
}
}
cout << "23%" << endl;
for(int x = 200;x < 2300;x++)
{
for(int y = 501 + stgd[x] + 1;y <= 700;y++)
{
if(world[x][y].id != 12) continue;
//海之环生成
bool flag = true;
for(int xx = x - 3;xx <= x + 5;xx++)
{
for(int yy = y - 3;yy <= y + 5;yy++)
{
if(world[xx][yy].id != 12) flag = false;
}
}
if(flag && random(1, 10000) < 6) //符合条件
{
bool haizhihuan[9][9] =
{
{0, 0, 1, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 0, 0, 0, 1, 1, 0},
{1, 1, 0, 0, 1, 0, 0, 1, 1},
{1, 0, 0, 1, 0, 1, 0, 0, 1},
{1, 0, 1, 0, 1, 0, 1, 0, 1},
{1, 0, 0, 1, 0, 1, 0, 0, 1},
{1, 1, 0, 0, 1, 0, 0, 1, 1},
{0, 1, 1, 0, 0, 0, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 1, 0, 0}};
for(int i = x - 5;i <= x + 5;i++)
{
for(int j = y - 5;j <= y + 5;j++)
{
if(haizhihuan[i - (x - 5)][j - (y - 5)] == 1)
{
block_copy(i, j, 21);
}
}
}
block_copy(x, y, 20);
}
}
}
cout << "27%" << endl;
//最上3层为泥土
for(int x = 200;x < 2300;x++)
{
int dian = random(1, 10000);
int tree = random(1, 10000);
block_copy(x, 501 + stgd[x], 2);
block_copy(x, 501 + stgd[x] + 1, 2);
block_copy(x, 501 + stgd[x] + 2, 2);
//生成树
if(tree <= 250)
{
block_copy(x, 501 + stgd[x] + 2, 4);
block_copy(x, 501 + stgd[x] + 3, 4);
block_copy(x, 501 + stgd[x] + 4, 4);
block_copy(x - 1, 501 + stgd[x] + 4, 11);
block_copy(x + 1, 501 + stgd[x] + 4, 11);
block_copy(x, 501 + stgd[x] + 5, 11);
block_copy(x - 1, 501 + stgd[x] + 5, 11);
block_copy(x + 1, 501 + stgd[x] + 5, 11);
block_copy(x, 501 + stgd[x] + 6, 11);
}
//生成高树
else if(tree <= 310)
{
block_copy(x, 501 + stgd[x] + 2, 4);
block_copy(x, 501 + stgd[x] + 3, 4);
block_copy(x, 501 + stgd[x] + 4, 4);
block_copy(x, 501 + stgd[x] + 5, 4);
block_copy(x - 1, 501 + stgd[x] + 4, 4);
block_copy(x + 1, 501 + stgd[x] + 4, 4);
block_copy(x - 2, 501 + stgd[x] + 5, 4);
block_copy(x + 2, 501 + stgd[x] + 5, 4);
block_copy(x - 2, 501 + stgd[x] + 6, 11);
block_copy(x + 2, 501 + stgd[x] + 6, 11);
block_copy(x - 2, 501 + stgd[x] + 4, 11);
block_copy(x + 2, 501 + stgd[x] + 4, 11);
block_copy(x, 501 + stgd[x] + 6, 11);
block_copy(x - 1, 501 + stgd[x] + 5, 11);
block_copy(x + 1, 501 + stgd[x] + 5, 11);
block_copy(x - 1, 501 + stgd[x] + 6, 11);
block_copy(x + 1, 501 + stgd[x] + 6, 11);
block_copy(x, 501 + stgd[x] + 6, 11);
block_copy(x, 501 + stgd[x] + 7, 11);
block_copy(x - 1, 501 + stgd[x] + 7, 11);
block_copy(x + 1, 501 + stgd[x] + 7, 11);
}
//生成入云树
else if(tree <= 340)
{
for(int i = 501 + stgd[x] + 2;i <= 501 + stgd[x] + (rand()%10) + 6;i++)
{
block_copy(x, i, 4);
if(i >= 501 + stgd[x] + 4)
{
block_copy(x - 1, i, 11);
block_copy(x + 1, i, 11);
}
block_copy(x, i + 1, 11);
}
}
//生成巨树
else if(tree <= 370)
{
block_copy(x, 501 + stgd[x] + 2, 4);
block_copy(x - 1, 501 + stgd[x] + 2, 4);
block_copy(x + 1, 501 + stgd[x] + 2, 4);
block_copy(x, 501 + stgd[x] + 3, 4);
block_copy(x - 1, 501 + stgd[x] + 3, 4);
block_copy(x + 1, 501 + stgd[x] + 3, 4);
block_copy(x, 501 + stgd[x] + 4, 4);
block_copy(x - 1, 501 + stgd[x] + 4, 4);
block_copy(x + 1, 501 + stgd[x] + 4, 4);
block_copy(x, 501 + stgd[x] + 5, 4);
block_copy(x - 1, 501 + stgd[x] + 5, 4);
block_copy(x + 1, 501 + stgd[x] + 5, 4);
block_copy(x - 2, 501 + stgd[x] + 4, 11);
block_copy(x + 2, 501 + stgd[x] + 4, 11);
block_copy(x - 2, 501 + stgd[x] + 5, 11);
block_copy(x + 2, 501 + stgd[x] + 5, 11);
block_copy(x - 2, 501 + stgd[x] + 6, 11);
block_copy(x + 2, 501 + stgd[x] + 6, 11);
block_copy(x - 1, 501 + stgd[x] + 6, 11);
block_copy(x + 1, 501 + stgd[x] + 6, 11);
block_copy(x, 501 + stgd[x] + 6, 11);
block_copy(x, 501 + stgd[x] + 7, 11);
block_copy(x - 1, 501 + stgd[x] + 7, 11);
block_copy(x + 1, 501 + stgd[x] + 7, 11);
}
//生成于苗神殿
else if(tree <= 405)
{
int y = 501 + stgd[x] + 3;
block_copy(x, y, 24);
block_copy(x - 1, y, 24);
block_copy(x + 1, y, 24);
block_copy(x - 2, y, 24);
block_copy(x + 2, y, 24);
block_copy(x - 3, y, 24);
block_copy(x + 3, y, 24);
block_copy(x - 3, y + 1, 24);
block_copy(x + 3, y + 1, 24);
block_copy(x - 3, y + 2, 24);
block_copy(x + 3, y + 2, 24);
block_copy(x - 3, y + 3, 24);
block_copy(x + 3, y + 3, 24);
block_copy(x - 3, y + 4, 24);
block_copy(x + 3, y + 4, 24);
block_copy(x - 3, y + 5, 24);
block_copy(x + 3, y + 5, 24);
block_copy(x - 3, y + 6, 24);
block_copy(x + 3, y + 6, 24);
block_copy(x - 2, y + 6, 24);
block_copy(x + 2, y + 6, 24);
block_copy(x - 1, y + 6, 24);
block_copy(x + 1, y + 6, 24);
block_copy(x, y + 6, 24);
block_copy(x - 2, y + 6, 24);
block_copy(x + 2, y + 6, 24);
block_copy(x - 2, y + 7, 24);
block_copy(x + 2, y + 7, 24);
block_copy(x - 1, y + 7, 26);
block_copy(x + 1, y + 7, 27);
block_copy(x - 2, y + 8, 24);
block_copy(x + 2, y + 8, 24);
block_copy(x - 1, y + 9, 24);
block_copy(x + 1, y + 9, 24);
block_copy(x, y + 9, 25);
block_copy(x - 1, y + 10, 24);
block_copy(x + 1, y + 10, 24);
block_copy(x, y + 10, 24);
}
//生成地牢
else if(tree <= 415 || x == 1200)
{
int t_high = rand() % 20 + 60;
for(int i = 0;i < 27;i++)
{
for(int j = 0;j < 29;j++)
{
int fangkuaiid = 0;
if(dilao_jiegou[i][j] == 1) continue;
else if(dilao_jiegou[i][j] == 2) fangkuaiid = 33;
else if(dilao_jiegou[i][j] == 3) fangkuaiid = 19;
else if(dilao_jiegou[i][j] == 5) fangkuaiid = 35;
else fangkuaiid = 34;
block_copy( x - 14 + j, 501 + stgd[x] + 3 - (t_high) + i, fangkuaiid);
}
}
}
}
cout << "30%" << endl;
for(int x = 200;x < 2300;x++)
{
int gaodu = max(741, 501 + stgd[x]);
for(int y = gaodu + 15;y <= gaodu + 20;y++)
{
if(rand() % 20000 < 1)
{
//生成宝藏岛
block_copy(x, y, 1);
for(int z = x - 2;z <= x + 2;z++) block_copy(z, y + 1, 1);
for(int z = x - 3;z <= x + 3;z++) block_copy(z, y + 2, 1);
for(int z = x - 4;z <= x + 4;z++) block_copy(z, y + 3, 1);
for(int z = x - 5;z <= x + 5;z++) block_copy(z, y + 4, 1);
block_copy(x - 2, y + 5, 9);
block_copy(x + 2, y + 5, 9);
block_copy(x - 2, y + 6, 7);
block_copy(x + 2, y + 6, 7);
block_copy(x - 2, y + 7, 5);
block_copy(x + 2, y + 7, 5);
block_copy(x - 1, y + 8, 22);
block_copy(x + 1, y + 8, 22);
block_copy(x, y + 6, 16);
block_copy(x, y + 10, 28);
break;
}
}
}
cout << "34%" << endl;
for(int x = 200;x < 2300;x++)
{
block_copy(x, 500, 14);
block_copy(x, 499, 14);
block_copy(x, 498, 14);
block_copy(x, 497, 14);
}
cout << "36%" << endl;
for(int x = 200;x < 2300;x++)
{
for(int y = 496;y >= 100;y--)
{
block_copy(x, y, 15);
if(random(0, 10000) <= 60)
{
bool flag = false;
if(random(0, 10000) <= 1000) flag = true;
int r = random(2, 4);
for(int xx = x - r;xx <= x + r;xx++)
{
for(int yy = y - r;yy <= y + r;yy++)
{
block_copy(xx, yy, 19);
if(yy == y - r)
{
if(flag) block_copy(xx, yy, 13);
}
}
}
}
//添加岩浆
if(random(0, 10000) <= 1000) block_copy(x, y, 13);
//远古残骸
if(random(0, 10000) <= 10) block_copy(x, y, 16);
}
}
cout << "42%" << endl;
for(int x = 200;x < 2300;x++)
{
for(int y = 496;y >= 100;y--)
{
//下界城市
if(random(1, 10000) == 1 || (x == 1200 && y == 400))
{
if(random(1, 100) == 1 || (x == 1200 && y == 400))
{
chengshi(x, y);
}
}
}
}
playery = 501 + stgd[1200] + 3;
}
void block_pick(BLOCK blk)
{
for(int i = 0;i < 5;i++)
{
if(fkl[i].id == blk.id && blk.id != 0 && fknum[i] < 64)
{
fkl[i].id = blk.id;
fkl[i].name = blk.name;
fkl[i].txt = blk.txt;
fkl[i].hard = blk.hard;
fkl[i].level = blk.level;
fkl[i].fluid = blk.fluid;
fkl[i].color = blk.color;
fknum[i];
return;
}
}
for(int i = 0;i < 5;i)
{
if(fknum[i] <= 0)
{
fkl[i].id = blk.id;
fkl[i].name = blk.name;
fkl[i].txt = blk.txt;
fkl[i].hard = blk.hard;
fkl[i].level = blk.level;
fkl[i].fluid = blk.fluid;
fkl[i].color = blk.color;
fknum[i] = 1;
return;
}
}
}
void block_delete(BLOCK blk)
{
for(int i = 0;i < 5;i++)
{
if(fkl[i].id == blk.id && fkl[i].txt == blk.txt)
{
fknum[i]--;
if(fknum[i] == 0)
{
fkl[i].id = 0;
fkl[i].name = "";
fkl[i].txt = "";
fkl[i].hard = 0;
fkl[i].level = 0;
fkl[i].fluid = 0;
fkl[i].color = 0;
}
return;
}
}
}
int block_num(BLOCK blk)
{
int num = 0;
for(int i = 0;i < 5;i++)
{
if(fkl[i].id == blk.id && fkl[i].txt == blk.txt)
{
num += fknum[i];
}
}
return num;
}
void item_pick(ITEM itm)
{
for(int i = 0;i < 5;i++)
{
if(wpl[i].id == itm.id && itm.id != 0 && wpnum[i] < 64)
{
wpl[i].id = itm.id;
wpl[i].hurt = itm.hurt;
wpl[i].level = itm.level;
wpl[i].name = itm.name;
wpl[i].speed = itm.speed;
wpl[i].rare = itm.rare;
wpnum[i];
return;
}
}
for(int i = 0;i < 5;i)
{
if(wpnum[i] <= 0)
{
wpl[i].id = itm.id;
wpl[i].hurt = itm.hurt;
wpl[i].level = itm.level;
wpl[i].name = itm.name;
wpl[i].speed = itm.speed;
wpl[i].rare = itm.rare;
wpnum[i] = 1;
return;
}
}
}
void item_delete(ITEM itm)
{
for(int i = 0;i < 5;i++)
{
if(wpl[i].id == itm.id && wpl[i].name == itm.name)
{
wpnum[i]--;
if(wpnum[i] == 0)
{
wpl[i].id = 0;
wpl[i].hurt = 0;
wpl[i].speed = 0;
wpl[i].level = 0;
wpl[i].name = "";
wpl[i].rare = 0;
}
return;
}
}
}
int item_num(ITEM itm)
{
int num = 0;
for(int i = 0;i < 5;i++)
{
if(wpl[i].id == itm.id && wpl[i].name == itm.name)
{
num += wpnum[i];
}
}
return num;
}
void armor_delete()
{
kjl.id = 0;
kjl.defease = 0;
kjl.name = "空";
}
void armor_pick(ARMOR arm)
{
kjl.id = arm.id;
kjl.defease = arm.defease;
kjl.name = arm.name;
}
void buff_give(BUFF bff, int level, int time)
{
if(bff.id == 0) return;
if(xgnum == xgmax) return;
xgl[xgnum].id = bff.id;
xgl[xgnum].level = level;
xgl[xgnum].name = bff.name;
xgl[xgnum++].time = time;
}
void buff_delete(BUFF bff)
{
if(bff.id == 0) return;
for(int i = 0;i < xgnum;i++)
{
if(xgl[i].id == bff.id)
{
xgl[i].id = 0;
xgl[i].level = 0;
xgl[i].name = "空";
xgl[i].time = 0;
}
}
}
int get_buff_level(BUFF bff)
{
int mx = 0;
if(bff.id == 0) return 0;
for(int i = 0;i < xgnum;i++)
{
if(xgl[i].id == bff.id) mx = max(mx, xgl[i].level);
}
return mx;
}
void buff_merge() //效果合并(每短刻进行)
{
for(int i = 0;i < xgnum;i++)
{
for(int j = i + 1;j < xgnum;j++)
{
if(xgl[i].id == xgl[j].id && xgl[i].id != 0)
{
xgl[i].level = max(xgl[i].level, xgl[j].level);
xgl[i].time = xgl[i].time + xgl[j].time;
xgl[j].id = 0;
xgl[j].level = 0;
xgl[j].name = "空";
xgl[j].time = 0;
xgnum--;
//迁移效果
for(int k = j + 1;k < xgnum + 1;k++)
{
xgl[k - 1].level = xgl[k].level;
xgl[k - 1].id = xgl[k].id;
xgl[k - 1].time = xgl[k].time;
xgl[k - 1].name = xgl[k].name;
xgl[k].id = 0;
xgl[k].level = 0;
xgl[k].name = "空";
xgl[k].time = 0;
}
}
}
}
}
void buff_live()
{
for(int i = 0;i < xgnum;i++)
{
if(xgl[i].id != 0)
{
xgl[i].time--;
if(xgl[i].time <= 0)
{
xgl[i].id = 0;
xgl[i].level = 0;
xgl[i].name = "空";
xgl[i].time = 0;
}
}
}
}
void attack(int hurt_num, string die_str) //造成伤害
{
if(gamemode == 1) return;
double hurt;
hurt = hurt_num * (1.0 - (kjl.defease) * 0.04);
//对高伤害进行削弱
int i = 0;
double shjm = 0.0;
for(int xxx = 0;xxx <= kjl.defease;xxx++)
{
shjm += 0.012 * (1.0 - (xxx * 0.04));
}
if(hurt >= 150)
{
hurt = 150 + sqrt(hurt - 150);
}
hurt -= hurt * 0.1 + shjm;
if(get_buff_level(buff[3]) > 0) hurt -= get_buff_level(buff[3]); //生命吸收
health -= hurt;
tick_attack = true;
if(health < 0 && gamemode == 2) //玩家死亡 极限模式=删除存档
{
system("cls");
SetPos(2, 2);
cout << "GAME OVER";
SetPos(2, 4);
cout << die_str;
SetPos(2, 6);
cout << "极限模式下 你必须删除存档";
init();
print_data();
SetPos(2, 8);
system("pause");
exit(0);
}
else if(health < 0 && gamemode == 0) //玩家死亡 生存模式=复活
{
system("cls");
SetPos(2, 2);
cout << "GAME OVER";
SetPos(2, 4);
cout << die_str;
SetPos(2, 6);
cout << "重生";
SetPos(2, 8);
system("pause");
playerx = 1200;
playery = 700;
block_copy(playerx, playery, 19);
health = max_health + get_buff_level(buff[1]) * 4;
return;
}
}
void input_data() //输入数据
{
ifstream fin("data.txt", ios::in);
for(int i = 0;i < 2400;i++)
{
for(int j = 0;j < 1200;j++)
{
int ijid;
fin >> ijid;
block_copy(i, j, ijid);
}
}
fin >> playerx >> playery;
for(int i = 0;i < 5;i++) fin >> fknum[i] >> wpnum[i];
for(int i = 0;i < 5;i++)
{
int fkid, wpid;
fin >> fkid >> wpid;
if(fkid != 0)
{
fkl[i].id = fkid;
fkl[i].fluid = block[fkid].fluid;
fkl[i].color = block[fkid].color;
fkl[i].hard = block[fkid].hard;
fkl[i].level = block[fkid].level;
fkl[i].txt = block[fkid].txt;
fkl[i].name = block[fkid].name;
}
else fknum[i] = 0;
if(wpid != 0)
{
wpl[i].id = wpid;
wpl[i].name = item[wpid].name;
wpl[i].speed = item[wpid].speed;
wpl[i].hurt = item[wpid].hurt;
wpl[i].level = item[wpid].level;
wpl[i].rare = item[wpid].rare;
}
else wpnum[i] = 0;
}
int zbid;
fin >> zbid;
armor_pick(armor[zbid]);
fin >> xgnum;
for(int i = 0;i < xgnum;i++)
{
int xgid, xgtm, xglv;
fin >> xgid >> xgtm >> xglv;
xgl[i].id = xgid;
xgl[i].time = xgtm;
xgl[i].name = buff[xgid].name;
xgl[i].level = xglv;
}
fin >> health >> oxygen;
fin >> gamemode;
fin >> level >> xp >> max_health;
}
void print_data() //输出数据
{
ofstream fout("data.txt", ios::out);
for(int i = 0;i < 2400;i++)
{
for(int j = 0;j < 1200;j++)
{
int id = world[i][j].id;
fout << id;
fout << ' ';
}
fout << endl;
}
fout << playerx << endl << playery << endl;
for(int i = 0;i < 5;i++) fout << fknum[i] << ' ' << wpnum[i] << endl;
for(int i = 0;i < 5;i++)
{
fout << fkl[i].id << ' ' << wpl[i].id << endl;
}
fout << kjl.id << endl;
fout << xgnum << endl;
for(int i = 0;i < xgnum;i++)
{
fout << xgl[i].id << ' ' << xgl[i].time << ' ' << xgl[i].level;
fout << endl;
}
fout << health << endl << oxygen << endl;
fout << gamemode << endl;
fout << level << endl << xp << endl << max_health << endl;
}
void item_choose() //创造物品选择器
{
system("cls");
SetPos(10, 1);
cout << "创造模式物品选择器:";
SetPos(10, 3);
cout << "a d 迭代手中物品 S 堆叠手中物品";
SetPos(10, 5);
cout << "K 确认";
while(1)
{
SetPos(10, 7);
cout << "手中物品:";
if(now <= 4) //显示方块
{
Color(fkl[now].color), cout << fkl[now].txt << ' ' << fkl[now].name;
cout << " ";
Color(0);
}
else //显示物品
{
if(wpl[now - 5].rare == 0) Color(0);
else if(wpl[now - 5].rare == 1) Color(1);
else if(wpl[now - 5].rare == 2) Color(3);
else if(wpl[now - 5].rare == 3) Color(4);
else Color(2);
cout << wpl[now - 5].name;
cout << " ";
Color(0);
}
Color(0);
if(_kbhit())
{
char f = _getch();
if(f == 'a')
{
if(now <= 4 && fkl[now].id > 0)
{
if(!fknum[now]) fknum[now];
fkl[now].id--;
fkl[now].color = block[fkl[now].id].color;
fkl[now].fluid = block[fkl[now].id].fluid;
fkl[now].hard = block[fkl[now].id].hard;
fkl[now].level = block[fkl[now].id].level;
fkl[now].name = block[fkl[now].id].name;
fkl[now].txt = block[fkl[now].id].txt;
}
else if(now >= 5 && wpl[now - 5].id > 0)
{
if(!wpnum[now - 5]) wpnum[now - 5];
wpl[now - 5].id--;
wpl[now - 5].hurt = item[wpl[now - 5].id].hurt;
wpl[now - 5].level = item[wpl[now - 5].id].level;
wpl[now - 5].name = item[wpl[now - 5].id].name;
wpl[now - 5].rare = item[wpl[now - 5].id].rare;
wpl[now - 5].speed = item[wpl[now - 5].id].speed;
}
}
else if(f == 'd')
{
if(now <= 4 && fkl[now].id < block_max)
{
if(!fknum[now]) fknum[now];
fkl[now].id;
fkl[now].color = block[fkl[now].id].color;
fkl[now].fluid = block[fkl[now].id].fluid;
fkl[now].hard = block[fkl[now].id].hard;
fkl[now].level = block[fkl[now].id].level;
fkl[now].name = block[fkl[now].id].name;
fkl[now].txt = block[fkl[now].id].txt;
}
else if(now >= 5 && wpl[now - 5].id < item_max)
{
if(!wpnum[now - 5]) wpnum[now - 5];
wpl[now - 5].id;
wpl[now - 5].hurt = item[wpl[now - 5].id].hurt;
wpl[now - 5].level = item[wpl[now - 5].id].level;
wpl[now - 5].name = item[wpl[now - 5].id].name;
wpl[now - 5].rare = item[wpl[now - 5].id].rare;
wpl[now - 5].speed = item[wpl[now - 5].id].speed;
}
}
else if(f == 's')
{
if(now <= 4) fknum[now] = 64;
else wpnum[now - 5] = 64;
}
else if(f == 'k')
{
system("cls");
return;
}
}
}
}
void crafting()
{
//合成
system("cls");
SetPos(10, 1);
cout << "合成";
SetPos(10, 3);
cout << "1 工具类";
SetPos(10, 5);
cout << "2 熔炼类";
SetPos(10, 7);
cout << "3 盔甲类";
SetPos(10, 9);
cout << "4 杂项";
SetPos(10, 11);
cout << "5 离开";
char cft0 = input('1', '5');
system("cls");
if(cft0 == '1')
{
SetPos(10, 1);
cout << "合成 - 工具类";
SetPos(10, 3);
cout << "1 木质";
SetPos(10, 5);
cout << "2 石质";
SetPos(10, 7);
cout << "3 铁质";
SetPos(10, 9);
cout << "4 金质";
SetPos(10, 11);
cout << "5 钻石/绿宝石质";
SetPos(10, 13);
cout << "6 合金质";
SetPos(10, 15);
cout << "7 灵魂物质";
SetPos(10, 17);
cout << "8 药水";
SetPos(10, 19);
cout << "9 离开";
char cft1 = input('1', '9');
system("cls");
if(cft1 == '1')
{
SetPos(10, 1);
cout << "合成 - 工具类 - 木质";
SetPos(10, 3);
cout << "1 木镐";
SetPos(10, 5);
cout << "2 木剑";
SetPos(10, 7);
cout << "3 离开";
char cft11 = input('1', '3');
if(cft11 == '1')
{
SetPos(10, 7);
cout << "需要 木头x4";
SetPos(10, 9);
cout << "1 确认";
SetPos(10, 11);
cout << "2 离开";
char cft111 = input('1', '2');
if(cft111 == '1')
{
if(block_num(block[4]) < 4) return;
block_delete(block[4]);
block_delete(block[4]);
这里空空如也
有帮助,赞一个