正文
增加 125 行删除 125 行
9 行未改动10111213141516171819202122232425262728293031323334353637385 行未改动44454647484950515228 行未改动8182838485868788899091929394959697989910010110210310410510626 行未改动13313413513613713813914014114214314414514614714814915015115215345 行未改动19920020120220320420520620720814 行未改动22322422522622722822923023123223323423523623723823924024124224324424524624724824925029 行未改动2802812822832842852862872884 行未改动2932942952962972982993003014 行未改动306307308309310311312313314402 行未改动全部展开7177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607615 行未改动7677687697707717727737747757 行未改动78378478578678778878979079179279379479579679779879980080125 行未改动8278288298308318328338348352 行未改动83883984084184284384484584617 行未改动86486586686786886987087187211 行未改动884885886887888889890891892104 行未改动全部展开99799899910001001100210031004100533 行未改动10391040104110421043104410451046104745 行未改动109310941095109610971098109911001101232 行未改动全部展开1334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136227 行未改动13901391139213931394139513961397139847 行未改动144614471448144914501451145214531454145514566 行未改动1463146414651466146714681469147014715 行未改动1477147814791480148114821483148414854 行未改动149014911492149314941495149614971498149915001501150215031504647 行未改动全部展开215221532154215521562157215821592160306 行未改动全部展开246724682469247024712472247324742475456 行未改动全部展开2932293329342935293629372938293929403 行未改动2944294529462947294829492950295129528 行未改动2961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299854 行未改动30533054305530563057305830593060306128 行未改动30903091309230933094309530963097309850 行未改动3149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319510 行未改动3206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132322 行未改动32353236323732383239324032413242324320 行未改动32643265326632673268326932703271327247 行未改动3320332133223323332433253326332733283329333033313332333382 行未改动34163417341834193420342134223423342487 行未改动35123513351435153516351735183519352087 行未改动36083609361036113612361336143615361643 行未改动366036613662366336643665366636673668269 行未改动全部展开39383939394039413942394339443945394646 行未改动39933994399539963997399839994000400127 行未改动4029403040314032403340344035403640374038403940404041404240434044404540464047404840494050132 行未改动全部展开418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420725 行未改动4233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425522 行未改动42784279428042814282428342844285428626 行未改动43134314431543164317431843194320432116 行未改动4338433943404341434243439 行未改动}Frame;void Color(int a){//白if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);//绿if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);//红if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);//蓝if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);//粉if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);//黄if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);//灰if(a==6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);//棕if(a==7) 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);}5 行未改动}void HideCursor(){CONSOLE_CURSOR_INFO cursor_info = {1, 0};SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);}char input()28 行未改动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},26 行未改动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},45 行未改动struct BUFF{int id;string name;int level; //等级 默认为0 1级以上显示在玩家属性页面中int time; //单位: short_tick 降至0后等级降至0级};BUFF buff[] = //效果{14 行未改动"获得护盾 每级提升1点免伤值","负面效果 每级每个构造刻受到1点伤害"};int gamemode = 0; //0=生存 1=创造 2=极限int short_tick = 0, tick = 0; //短刻(每秒10次)和构造刻(每秒1次)BLOCK world[2400][1200]; //地图 x0~2399 y0~1199BLOCK fkl[5]; //方块栏ITEM wpl[5]; //物品栏ARMOR kjl = armor[0]; //盔甲栏 做出盔甲立即替换const int xgmax = 5; //可获得的效果总数BUFF xgl[xgmax]; //效果栏int xgnum; //已拥有BUFFint 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();29 行未改动};//下界城市//核心int nc_core[9][9] ={{0, 0, 0, 1, 2, 1, 0, 0, 0},{0, 0, 1, 1, 2, 1, 1, 0, 0},{0, 1, 1, 2, 2, 2, 1, 1, 0},4 行未改动{0, 0, 1, 1, 2, 1, 1, 0, 0},{0, 0, 0, 1, 2, 1, 0, 0, 0}};//水平廊道int nc_cz_ld[9][9] ={{0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0},4 行未改动{0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0}};//垂直廊道int nc_sp_ld[9][9] ={{0, 0, 0, 1, 2, 1, 0, 0, 0},{0, 0, 0, 1, 2, 1, 0, 0, 0},{0, 0, 0, 1, 2, 1, 0, 0, 0},402 行未改动全部展开}}}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++)5 行未改动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];7 行未改动{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);}25 行未改动{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++)2 行未改动}}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},17 行未改动}}}cout << "27%" << endl;//最上3层为泥土for(int x = 200;x < 2300;x++){int dian = random(1, 10000);int tree = random(1, 10000);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);104 行未改动全部展开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++)33 行未改动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;}}}45 行未改动if(random(1, 100) == 1 || (x == 1200 && y == 400)){chengshi(x, y);}}}}playery = 501 + stgd[1200] + 3;}232 行未改动全部展开}}}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";27 行未改动}void input_data() //输入数据{ifstream fin("data.txt", ios::in);for(int i = 0;i < 2400;i++){for(int j = 0;j < 1200;j++){47 行未改动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++){6 行未改动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++)5 行未改动fout << gamemode << endl;fout << level << endl << xp << endl << max_health << endl;}void item_choose() //创造物品选择器{system("cls");SetPos(10, 1);cout << "创造模式物品选择器:";4 行未改动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);647 行未改动全部展开cout << "1 灵魂镐";SetPos(10, 5);cout << "2 灵魂剑";SetPos(10, 7);cout << "3 灵魂之星";SetPos(10, 9);cout << "3 离开";char cft16 = input('1', '4');if(cft16 == '1')306 行未改动全部展开}}else if(cft21 == '5'){return;}}else if(cft2 == '2'){456 行未改动全部展开system("cls");while(1){Sleep(100);//时刻流逝short_tick++;if(short_tick == 10){short_tick = 0;3 行未改动if(zhongdulevel > 0) attack(zhongdulevel, "玩家中毒而死");}if(jianweitishi) jianweitishi--;if(wajuetishi) wajuetishi--;//处理药水效果buff_merge();buff_live();//处理生命溢出8 行未改动{i++;xp -= 100 + (level + 1) * 10;level++;if(level % 2 == 0) max_health++; //每两级加一滴血}SetPos(0, 0);cout << "世界与我 Craft And My";SetPos(0, 1);if(get_buff_level(buff[4])) Color(5);else Color(2);double the_mx = max_health + get_buff_level(buff[1]) * 4; //生命上限int h = health;int heart = h / the_mx * 10;for(int i = 0;i < heart;i++) cout << "◆"; //生命值int y = h / (the_mx / 10);for(int z = heart;z < 10;z++) cout << "◇";cout << ' ' << fixed << setprecision(1) << health << " ";Color(0);SetPos(0, 2);Color(3);for(int i = 2;i <= oxygen;i += 2) cout << "●"; //氧气值int u = oxygen / 2;for(int v = u + 1;v <= 10;v++) cout << "○";cout << ' ' << fixed << setprecision(1) << oxygen << " ";Color(0);SetPos(0, 3);for(int i = 2;i <= kjl.defease;i += 2) cout << "▼"; //盔甲SetPos(69, 2); //输出玩家坐标cout << "X:" << playerx;SetPos(69, 4);cout << "Y:" << playery;for(int i = 0;i < 5;i++) //打印物品栏 方块栏{SetPos(69, 6 + i * 2);if(now == i) Color(5);else if(wajuetishi) Color(2);54 行未改动cout << "S键保存当前存档";if(gamemode == 0 || gamemode == 2){SetPos(0, 28);cout << "Q键摧毁手持物品";}else{SetPos(0, 28);28 行未改动else if(j == playerx - 1 && i == playery){Color(5), cout << "A<";Color(0);continue;}else if(j == playerx + 1 && i == playery){Color(5), cout << "D>";50 行未改动{health++;if(health > the_mx) health = the_mx;}//重力下落if(zhuiluo < 4 && (tick * 10 + short_tick) % 3 == 0){if(world[playerx][playery - 1].fluid){playery--;zhuiluo++;}else //落地{if(zhuiluo > 9) attack((zhuiluo - 9), "玩家摔死了");//摔落伤害zhuiluo = 0;}}//快速下落else if(zhuiluo >= 4 && zhuiluo < 8 && short_tick % 2 == 0){if(world[playerx][playery - 1].fluid){playery--;zhuiluo++;}else //落地{if(zhuiluo > 9) attack((zhuiluo - 9), "玩家摔死了"); //摔落伤害zhuiluo = 0;}}//危险下落else if(zhuiluo >= 8 && short_tick % 3 <= 1){if(world[playerx][playery - 1].fluid){playery--;zhuiluo++;}else //落地{if(zhuiluo > 9) attack(sqrt(zhuiluo - 9), "玩家摔死了"); //摔落伤害zhuiluo = 0;}}//岩浆10 行未改动if(world[playerx][playery].id == 35){attack(5, "玩家在死水中化为飞灰");}//氧气值下降if(short_tick == 0){if(world[playerx][playery].fluid && !(world[playerx][playery].name == "空气")){oxygen--;if(oxygen < 0){//氧气耗尽oxygen = 0;attack(1, "玩家窒息而死");}}else if(oxygen < 20){oxygen++; //若玩家不在流体中则恢复氧气}}if(energy > 0) //跳跃{if(world[playerx][playery + 1].fluid){playery++;2 行未改动else energy = 0;if(energy < 0) energy = 0;}char x;if(_kbhit()) //按键点击{x = _getch();if(x == 'a'){20 行未改动{now = x - '0';wjjd = 0;}else if(x == 'i') //挖掘上方方块/放置方块在上方{//桶的收集判定if(now >= 5 && wpl[now - 5].id == 18){47 行未改动block_copy(playerx, playery + 1, 32);Sleep(1000);bomb(playerx, playery + 1, 4);}//其它判定if(world[playerx][playery + 1].fluid && now <= 4){wajuetishi = 20;if(fknum[now] > 0 && fkl[now].id != 0){block_copy(playerx, playery + 1, fkl[now].id);block_delete(fkl[now]);}}82 行未改动block_copy(playerx, playery - 1, 32);Sleep(1000);bomb(playerx, playery - 1, 4);}//其它判定if(world[playerx][playery - 1].fluid && now <= 4){wajuetishi = 20;if(fknum[now] > 0 && fkl[now].id != 0)87 行未改动block_copy(playerx - 1, playery, 32);Sleep(1000);bomb(playerx - 1, playery, 4);}//其它判定if(world[playerx - 1][playery].fluid && now <= 4){wajuetishi = 20;if(fknum[now] > 0 && fkl[now].id != 0)87 行未改动block_copy(playerx + 1, playery, 32);Sleep(1000);bomb(playerx + 1, playery, 4);}//其它判定if(world[playerx + 1][playery].fluid && now <= 4){wajuetishi = 20;if(fknum[now] > 0 && fkl[now].id != 0)43 行未改动print_data();}else if(x == 'q'){if(gamemode == 1) item_choose(); //创造物品选择器else if(now >= 4) wpnum[now - 5]--;}else if(x == 'z'){269 行未改动全部展开SetPos(2, 8);cout << "现在向左移动";x = input('a', 'a');SetPos(44, 6);Color(5), cout << "d";SetPos(2, 8);cout << "现在向右移动";x = input('d', 'd');SetPos(2, 8);46 行未改动Color(cnt[2]), cout << "l";SetPos(62, 8);Color(cnt[3]), cout << "k";char y = ' ';if(_kbhit()) y = input();if(y == 'i') cnt[0] = max(cnt[0] - 1, 0);if(y == 'j') cnt[1] = max(cnt[1] - 1, 0);if(y == 'l') cnt[2] = max(cnt[2] - 1, 0);if(y == 'k') cnt[3] = max(cnt[3] - 1, 0);27 行未改动}int main(){//世界准备system("mode con cols=130 lines=35");srand(time(0));HideCursor();SetConsoleTitle("世界与我 0.8_v2.3");cundang:cout << "Craft and My: 世界与我" << endl;cout << "1 使用原先存档" << endl;cout << "2 重置新的世界" << endl;cout << "3 查看更新日志" << endl;cout << "4 新手教程(";Color(5), cout << "新人必看";Color(0), cout << ")" << endl;cout << "版本: 测试版0.8_v2.3" << endl;char n = input('1', '4');if(n == '1') input_data();else if(n == '2'){132 行未改动全部展开Color(6), cout << "内部版0.7pre3" << endl, Color(0);cout << "- 修改游戏名称" << endl;system("pause");system("cls");break;case '7':Color(6), cout << "内部版0.7pre4" << endl, Color(0);cout << "- 修复一些漏洞" << endl;system("pause");system("cls");break;case '8':Color(5), cout << "测试版0.7" << endl, Color(0);cout << "- 修改give命令" << endl;cout << "- 新增1个命令" << endl;cout << "- 修改主界面" << endl;cout << "- 重置存档时允许输入种子" << endl;cout << "- 修复一些漏洞" << endl;system("pause");system("cls");break;case '9':Color(5), cout << "测试版0.7a" << endl, Color(0);cout << "- 修改提升了程序的兼容性" << endl;system("pause");25 行未改动cout << "- 全新结构:宝藏岛登场!" << endl;cout << "- 下界地形优化:不再填满方块!" << endl;cout << "- 新增多个物品、方块" << endl;cout << "- 新增等级系统" << endl;cout << "- 其它一些小改动or小优化" << endl;system("pause");system("cls");break;case '4':Color(6), cout << "内部版0.8pre1.1" << endl, Color(0);cout << "- 宝藏探测器的一点小更改" << endl;cout << "- 补上了0.8pre1漏掉的一个小改动" << endl;cout << "- 等级系统BUG修复" << endl;system("pause");system("cls");break;case '5':Color(6), cout << "内部版0.8pre1.2" << endl, Color(0);cout << "- 大整改!!!" << endl;cout << "- 爆炸更新:添加了巨大的爆炸系统!" << endl;cout << "- 指令更新:增加了许多种指令!" << endl;cout << "- 伤害更新:大幅提升了高伤害时的减免!" << endl;cout << "- 经验更新:经验等级现在与生命值和挖掘速度挂钩!" << endl;22 行未改动cout << "- 修复了死亡后重生在地底的BUG" << endl;cout << "- 新增一个修改氧气值的指令" << endl;cout << "- 更改伤害指令的死亡信息" << endl;system("pause");system("cls");break;case '9':Color(5), cout << "测试版0.8_v2" << endl, Color(0);cout << "- 灵魂地牢更新:" << endl;26 行未改动cout << "- 改摔伤 降低了摔落伤害 同时修复了单次坠落格数过高时无法再跳跃的问题" << endl;cout << "- 修改了硬度系统 增高降低了某些方块的硬度 调高了一些镐子的挖掘速度" << endl;cout << "- 增大了海之环" << endl;system("pause");system("cls");case '3':Color(5), cout << "测试版0.8_v2.3" << endl, Color(0);cout << "- 修改宝藏岛 让它的生成变得更难" << endl;cout << "- 增加了未完成的下界要塞:生成机制重做中" << endl;16 行未改动system("cls");jiaocheng();}minecraft();return 0;}9 行未改动10111213141516171819202122232425262728293031323334353637385 行未改动44454647484950515228 行未改动8182838485868788899091929394959697989910010110210310410510626 行未改动13313413513613713813914014114214314414514614714814915015115215345 行未改动19920020120220320420520620720814 行未改动22322422522622722822923023123223323423523623723823924024124224324424524624724824925029 行未改动2802812822832842852862872884 行未改动2932942952962972982993003014 行未改动306307308309310311312313314402 行未改动全部展开7177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607615 行未改动7677687697707717727737747757 行未改动78378478578678778878979079179279379479579679779879980080125 行未改动8278288298308318328338348352 行未改动83883984084184284384484584617 行未改动86486586686786886987087187211 行未改动884885886887888889890891892104 行未改动全部展开99799899910001001100210031004100533 行未改动10391040104110421043104410451046104745 行未改动109310941095109610971098109911001101232 行未改动全部展开1334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136227 行未改动13901391139213931394139513961397139847 行未改动144614471448144914501451145214531454145514566 行未改动1463146414651466146714681469147014715 行未改动1477147814791480148114821483148414854 行未改动149014911492149314941495149614971498149915001501150215031504647 行未改动全部展开215221532154215521562157215821592160306 行未改动全部展开246724682469247024712472247324742475456 行未改动全部展开2932293329342935293629372938293929403 行未改动2944294529462947294829492950295129528 行未改动2961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299854 行未改动30533054305530563057305830593060306128 行未改动30903091309230933094309530963097309850 行未改动3149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319510 行未改动3206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132322 行未改动32353236323732383239324032413242324320 行未改动32643265326632673268326932703271327247 行未改动3320332133223323332433253326332733283329333033313332333382 行未改动34163417341834193420342134223423342487 行未改动35123513351435153516351735183519352087 行未改动36083609361036113612361336143615361643 行未改动366036613662366336643665366636673668269 行未改动全部展开39383939394039413942394339443945394646 行未改动39933994399539963997399839994000400127 行未改动4029403040314032403340344035403640374038403940404041404240434044404540464047404840494050132 行未改动全部展开418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420725 行未改动4233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425522 行未改动42784279428042814282428342844285428626 行未改动43134314431543164317431843194320432116 行未改动4338433943404341434243439 行未改动}Frame;void Color(int a){//白if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);//绿if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);//红if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);//蓝if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);//粉if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);//黄if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);//灰if(a==6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);//棕if(a==7) 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);}5 行未改动}void HideCursor(){CONSOLE_CURSOR_INFO cursor_info = {1, 0};SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);}char input()28 行未改动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},26 行未改动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},45 行未改动struct BUFF{int id;string name;int level; //等级 默认为0 1级以上显示在玩家属性页面中int time; //单位: short_tick 降至0后等级降至0级};BUFF buff[] = //效果{14 行未改动"获得护盾 每级提升1点免伤值","负面效果 每级每个构造刻受到1点伤害"};int gamemode = 0; //0=生存 1=创造 2=极限int short_tick = 0, tick = 0; //短刻(每秒10次)和构造刻(每秒1次)BLOCK world[2400][1200]; //地图 x0~2399 y0~1199BLOCK fkl[5]; //方块栏ITEM wpl[5]; //物品栏ARMOR kjl = armor[0]; //盔甲栏 做出盔甲立即替换const int xgmax = 5; //可获得的效果总数BUFF xgl[xgmax]; //效果栏int xgnum; //已拥有BUFFint 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();29 行未改动};//下界城市//核心int nc_core[9][9] ={{0, 0, 0, 1, 2, 1, 0, 0, 0},{0, 0, 1, 1, 2, 1, 1, 0, 0},{0, 1, 1, 2, 2, 2, 1, 1, 0},4 行未改动{0, 0, 1, 1, 2, 1, 1, 0, 0},{0, 0, 0, 1, 2, 1, 0, 0, 0}};//水平廊道int nc_cz_ld[9][9] ={{0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0},4 行未改动{0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0}};//垂直廊道int nc_sp_ld[9][9] ={{0, 0, 0, 1, 2, 1, 0, 0, 0},{0, 0, 0, 1, 2, 1, 0, 0, 0},{0, 0, 0, 1, 2, 1, 0, 0, 0},402 行未改动全部展开}}}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++)5 行未改动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];7 行未改动{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);}25 行未改动{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++)2 行未改动}}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},17 行未改动}}}cout << "27%" << endl;//最上3层为泥土for(int x = 200;x < 2300;x++){int dian = random(1, 10000);int tree = random(1, 10000);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);104 行未改动全部展开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++)33 行未改动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;}}}45 行未改动if(random(1, 100) == 1 || (x == 1200 && y == 400)){chengshi(x, y);}}}}playery = 501 + stgd[1200] + 3;}232 行未改动全部展开}}}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";27 行未改动}void input_data() //输入数据{ifstream fin("data.txt", ios::in);for(int i = 0;i < 2400;i++){for(int j = 0;j < 1200;j++){47 行未改动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++){6 行未改动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++)5 行未改动fout << gamemode << endl;fout << level << endl << xp << endl << max_health << endl;}void item_choose() //创造物品选择器{system("cls");SetPos(10, 1);cout << "创造模式物品选择器:";4 行未改动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);647 行未改动全部展开cout << "1 灵魂镐";SetPos(10, 5);cout << "2 灵魂剑";SetPos(10, 7);cout << "3 灵魂之星";SetPos(10, 9);cout << "3 离开";char cft16 = input('1', '4');if(cft16 == '1')306 行未改动全部展开}}else if(cft21 == '5'){return;}}else if(cft2 == '2'){456 行未改动全部展开system("cls");while(1){Sleep(100);//时刻流逝short_tick++;if(short_tick == 10){short_tick = 0;3 行未改动if(zhongdulevel > 0) attack(zhongdulevel, "玩家中毒而死");}if(jianweitishi) jianweitishi--;if(wajuetishi) wajuetishi--;//处理药水效果buff_merge();buff_live();//处理生命溢出8 行未改动{i++;xp -= 100 + (level + 1) * 10;level++;if(level % 2 == 0) max_health++; //每两级加一滴血}SetPos(0, 0);cout << "世界与我 Craft And My";SetPos(0, 1);if(get_buff_level(buff[4])) Color(5);else Color(2);double the_mx = max_health + get_buff_level(buff[1]) * 4; //生命上限int h = health;int heart = h / the_mx * 10;for(int i = 0;i < heart;i++) cout << "◆"; //生命值int y = h / (the_mx / 10);for(int z = heart;z < 10;z++) cout << "◇";cout << ' ' << fixed << setprecision(1) << health << " ";Color(0);SetPos(0, 2);Color(3);for(int i = 2;i <= oxygen;i += 2) cout << "●"; //氧气值int u = oxygen / 2;for(int v = u + 1;v <= 10;v++) cout << "○";cout << ' ' << fixed << setprecision(1) << oxygen << " ";Color(0);SetPos(0, 3);for(int i = 2;i <= kjl.defease;i += 2) cout << "▼"; //盔甲SetPos(69, 2); //输出玩家坐标cout << "X:" << playerx;SetPos(69, 4);cout << "Y:" << playery;for(int i = 0;i < 5;i++) //打印物品栏 方块栏{SetPos(69, 6 + i * 2);if(now == i) Color(5);else if(wajuetishi) Color(2);54 行未改动cout << "S键保存当前存档";if(gamemode == 0 || gamemode == 2){SetPos(0, 28);cout << "Q键摧毁手持物品";}else{SetPos(0, 28);28 行未改动else if(j == playerx - 1 && i == playery){Color(5), cout << "A<";Color(0);continue;}else if(j == playerx + 1 && i == playery){Color(5), cout << "D>";50 行未改动{health++;if(health > the_mx) health = the_mx;}//重力下落if(zhuiluo < 4 && (tick * 10 + short_tick) % 3 == 0){if(world[playerx][playery - 1].fluid){playery--;zhuiluo++;}else //落地{if(zhuiluo > 9) attack((zhuiluo - 9), "玩家摔死了");//摔落伤害zhuiluo = 0;}}//快速下落else if(zhuiluo >= 4 && zhuiluo < 8 && short_tick % 2 == 0){if(world[playerx][playery - 1].fluid){playery--;zhuiluo++;}else //落地{if(zhuiluo > 9) attack((zhuiluo - 9), "玩家摔死了"); //摔落伤害zhuiluo = 0;}}//危险下落else if(zhuiluo >= 8 && short_tick % 3 <= 1){if(world[playerx][playery - 1].fluid){playery--;zhuiluo++;}else //落地{if(zhuiluo > 9) attack(sqrt(zhuiluo - 9), "玩家摔死了"); //摔落伤害zhuiluo = 0;}}//岩浆10 行未改动if(world[playerx][playery].id == 35){attack(5, "玩家在死水中化为飞灰");}//氧气值下降if(short_tick == 0){if(world[playerx][playery].fluid && !(world[playerx][playery].name == "空气")){oxygen--;if(oxygen < 0){//氧气耗尽oxygen = 0;attack(1, "玩家窒息而死");}}else if(oxygen < 20){oxygen++; //若玩家不在流体中则恢复氧气}}if(energy > 0) //跳跃{if(world[playerx][playery + 1].fluid){playery++;2 行未改动else energy = 0;if(energy < 0) energy = 0;}char x;if(_kbhit()) //按键点击{x = _getch();if(x == 'a'){20 行未改动{now = x - '0';wjjd = 0;}else if(x == 'i') //挖掘上方方块/放置方块在上方{//桶的收集判定if(now >= 5 && wpl[now - 5].id == 18){47 行未改动block_copy(playerx, playery + 1, 32);Sleep(1000);bomb(playerx, playery + 1, 4);}//其它判定if(world[playerx][playery + 1].fluid && now <= 4){wajuetishi = 20;if(fknum[now] > 0 && fkl[now].id != 0){block_copy(playerx, playery + 1, fkl[now].id);block_delete(fkl[now]);}}82 行未改动block_copy(playerx, playery - 1, 32);Sleep(1000);bomb(playerx, playery - 1, 4);}//其它判定if(world[playerx][playery - 1].fluid && now <= 4){wajuetishi = 20;if(fknum[now] > 0 && fkl[now].id != 0)87 行未改动block_copy(playerx - 1, playery, 32);Sleep(1000);bomb(playerx - 1, playery, 4);}//其它判定if(world[playerx - 1][playery].fluid && now <= 4){wajuetishi = 20;if(fknum[now] > 0 && fkl[now].id != 0)87 行未改动block_copy(playerx + 1, playery, 32);Sleep(1000);bomb(playerx + 1, playery, 4);}//其它判定if(world[playerx + 1][playery].fluid && now <= 4){wajuetishi = 20;if(fknum[now] > 0 && fkl[now].id != 0)43 行未改动print_data();}else if(x == 'q'){if(gamemode == 1) item_choose(); //创造物品选择器else if(now >= 4) wpnum[now - 5]--;}else if(x == 'z'){269 行未改动全部展开SetPos(2, 8);cout << "现在向左移动";x = input('a', 'a');SetPos(44, 6);Color(5), cout << "d";SetPos(2, 8);cout << "现在向右移动";x = input('d', 'd');SetPos(2, 8);46 行未改动Color(cnt[2]), cout << "l";SetPos(62, 8);Color(cnt[3]), cout << "k";char y = ' ';if(_kbhit()) y = input();if(y == 'i') cnt[0] = max(cnt[0] - 1, 0);if(y == 'j') cnt[1] = max(cnt[1] - 1, 0);if(y == 'l') cnt[2] = max(cnt[2] - 1, 0);if(y == 'k') cnt[3] = max(cnt[3] - 1, 0);27 行未改动}int main(){//世界准备system("mode con cols=130 lines=35");srand(time(0));HideCursor();SetConsoleTitle("世界与我 0.8_v2.3");cundang:cout << "Craft and My: 世界与我" << endl;cout << "1 使用原先存档" << endl;cout << "2 重置新的世界" << endl;cout << "3 查看更新日志" << endl;cout << "4 新手教程(";Color(5), cout << "新人必看";Color(0), cout << ")" << endl;cout << "版本: 测试版0.8_v2.3" << endl;char n = input('1', '4');if(n == '1') input_data();else if(n == '2'){132 行未改动全部展开Color(6), cout << "内部版0.7pre3" << endl, Color(0);cout << "- 修改游戏名称" << endl;system("pause");system("cls");break;case '7':Color(6), cout << "内部版0.7pre4" << endl, Color(0);cout << "- 修复一些漏洞" << endl;system("pause");system("cls");break;case '8':Color(5), cout << "测试版0.7" << endl, Color(0);cout << "- 修改give命令" << endl;cout << "- 新增1个命令" << endl;cout << "- 修改主界面" << endl;cout << "- 重置存档时允许输入种子" << endl;cout << "- 修复一些漏洞" << endl;system("pause");system("cls");break;case '9':Color(5), cout << "测试版0.7a" << endl, Color(0);cout << "- 修改提升了程序的兼容性" << endl;system("pause");25 行未改动cout << "- 全新结构:宝藏岛登场!" << endl;cout << "- 下界地形优化:不再填满方块!" << endl;cout << "- 新增多个物品、方块" << endl;cout << "- 新增等级系统" << endl;cout << "- 其它一些小改动or小优化" << endl;system("pause");system("cls");break;case '4':Color(6), cout << "内部版0.8pre1.1" << endl, Color(0);cout << "- 宝藏探测器的一点小更改" << endl;cout << "- 补上了0.8pre1漏掉的一个小改动" << endl;cout << "- 等级系统BUG修复" << endl;system("pause");system("cls");break;case '5':Color(6), cout << "内部版0.8pre1.2" << endl, Color(0);cout << "- 大整改!!!" << endl;cout << "- 爆炸更新:添加了巨大的爆炸系统!" << endl;cout << "- 指令更新:增加了许多种指令!" << endl;cout << "- 伤害更新:大幅提升了高伤害时的减免!" << endl;cout << "- 经验更新:经验等级现在与生命值和挖掘速度挂钩!" << endl;22 行未改动cout << "- 修复了死亡后重生在地底的BUG" << endl;cout << "- 新增一个修改氧气值的指令" << endl;cout << "- 更改伤害指令的死亡信息" << endl;system("pause");system("cls");break;case '9':Color(5), cout << "测试版0.8_v2" << endl, Color(0);cout << "- 灵魂地牢更新:" << endl;26 行未改动cout << "- 改摔伤 降低了摔落伤害 同时修复了单次坠落格数过高时无法再跳跃的问题" << endl;cout << "- 修改了硬度系统 增高降低了某些方块的硬度 调高了一些镐子的挖掘速度" << endl;cout << "- 增大了海之环" << endl;system("pause");system("cls");case '3':Color(5), cout << "测试版0.8_v2.3" << endl, Color(0);cout << "- 修改宝藏岛 让它的生成变得更难" << endl;cout << "- 增加了未完成的下界要塞:生成机制重做中" << endl;16 行未改动system("cls");jiaocheng();}minecraft();return 0;}