新手天翼
/*
0=黑色
1=蓝色
2=绿色
3=湖蓝色
4=红色
5=紫色
6=**
7=白色
8=灰色
9=淡蓝色
A=淡绿色
B=淡浅绿色
C=淡红色
D=淡紫色
E=淡黄
F=亮白色
*/
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <time.h>
#include <windows.h>
#include <pthread.h>
#include <conio.h>
#include <vector>
#include <map>
using namespace std;
int gold=6;
int diamond=1;
HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE), hsout;
HWND hwnd = GetConsoleWindow();
string xs;
//基**操作函数
void gotoxy(short x, short y) { //移动光标函数
COORD coord = {x, y};
SetConsoleCursorPosition(hout, coord);
}
void cursor(bool visible) { //控制光标函数
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(hout, &CursorInfo);
CursorInfo.bVisible = visible;
SetConsoleCursorInfo(hout, &CursorInfo);
}
void color(int ForgC, int BackC) { //设置颜色函数
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
SetConsoleTextAttribute(hout, wColor);
}
void generation(int);
WORD get_font(int ForgC, int BackC) { //获取字体颜色参数
return ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
}
void color(int ForgC) {
WORD wColor;
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (GetConsoleScreenBufferInfo(hout, &csbi)) {
wColor = (csbi.wAttributes & 0xF0) + (ForgC & 0x0F);
SetConsoleTextAttribute(hout, wColor);
}
}
void nofastedit() { //关闭快速编辑
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
DWORD mode;
GetConsoleMode(hStdin, &mode);
mode &= ~ENABLE_QUICK_EDIT_MODE;
mode &= ~ENABLE_INSERT_MODE;
mode &= ~ENABLE_MOUSE_INPUT;
SetConsoleMode(hStdin, mode);
}
COORD home_coord = {0, 0};
DWORD written;
void write(const char *str, int ssize) { //快速渲染
WriteConsoleOutputCharacterA(hout, str, ssize, home_coord, &written);
}
void writefont(const WORD *font, int fsize) { //快速渲染颜色信息
WriteConsoleOutputAttribute(hout, font, fsize, home_coord, &written);
}
bool keydown(int key) { //判断键状态
return GetAsyncKeyState(key);
}
int setfontsize(int x, int y) { //设置字体大小
CONSOLE_FONT_INFOEX cfi;
GetCurrentConsoleFontEx(hout, FALSE, &cfi);
cfi.cbSize = sizeof(cfi);
cfi.nFont = 0;
cfi.dwFontSize.X = x;
cfi.dwFontSize.Y = y;
cfi.FontFamily = FF_DONTCARE;
cfi.FontWeight = 400;
wcscpy(cfi.FaceName, L"NSimSun");
return SetCurrentConsoleFontEx(hout, TRUE, &cfi);
}
int rand(int a, int b) { //rand()随机数
return (rand() % (b - a + 1)) + a;
}
void swrite(string str) { //输出到设置缓冲区
WriteConsoleA(hsout, str.c_str(), str.size(), NULL, NULL);
}
bool access(string name) { //判断文件是否存在
ifstream f(name.c_str());
return f.good();
}
int nozero(int k) {
if (k < 0) {
return 0;
} else {
return k;
}
}
bool jianzao;
//常量
int blocks[1000][10][10] = {
{
//0:air(空气)
{15, 15, 15, 15, 15, 15, 15, 15, 15, 15},
{15, 15, 15, 15, 15, 15, 15, 15, 15, 15},
{15, 15, 15, 15, 15, 15, 15, 15, 15, 15},
{15, 15, 15, 15, 15, 15, 15, 15, 15, 15},
{15, 15, 15, 15, 15, 15, 15, 15, 15, 15},
{15, 15, 15, 15, 15, 15, 15, 15, 15, 15},
{15, 15, 15, 15, 15, 15, 15, 15, 15, 15},
{15, 15, 15, 15, 15, 15, 15, 15, 15, 15},
{15, 15, 15, 15, 15, 15, 15, 15, 15, 15},
{15, 15, 15, 15, 15, 15, 15, 15, 15, 15},
},
{
//1:grass_block(草方块)
{2, 10, 2, 10, 2, 10, 2, 10, 2, 10},
{10, 2, 10, 2, 10, 2, 10, 2, 10, 2},
{2, 6, 2, 6, 2, 6, 2, 6, 2, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6}
},
{
//2:dirt(泥土)
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
{6, 6, 6, 6, 6, 6, 6, 6, 6, 6}
},
{
//3:stone(石头)
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
},
{
//4:none(基岩)
{0, 8, 0, 8, 0, 8, 0, 8, 0, 8},
{8, 0, 8, 0, 8, 0, 8, 0, 8, 0},
{0, 8, 0, 8, 0, 8, 0, 8, 0, 8},
{8, 0, 8, 0, 8, 0, 8, 0, 8, 0},
{0, 8, 0, 8, 0, 8, 0, 8, 0, 8},
{8, 0, 8, 0, 8, 0, 8, 0, 8, 0},
{0, 8, 0, 8, 0, 8, 0, 8, 0, 8},
{8, 0, 8, 0, 8, 0, 8, 0, 8, 0},
{0, 8, 0, 8, 0, 8, 0, 8, 0, 8},
{8, 0, 8, 0, 8, 0, 8, 0, 8, 0},
},
{
//5:water(水)
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9}
},
{
//6:木头
{4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 4, 4, 4, 4, 4, 4, 4, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 4, 0, 4},
{4, 0, 4, 4, 4, 4, 0, 4, 0, 4},
{4, 0, 4, 4, 0, 0, 0, 4, 0, 4},
{4, 0, 4, 4, 4, 4, 4, 4, 0, 4},
{4, 0, 4, 4, 4, 4, 4, 4, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
}
,
{
//7:叶子
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
}
,{
//8:iron
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8,8, 8, 7,7, 8, 8, 8},
{8, 8, 7, 7, 8, 8, 8, 8, 8, 8},
{7, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8,8, 7, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 7, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 7, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
}
,{
//9:diamond
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8,8, 8, diamond,diamond, 8, 8, 8},
{8, 8, diamond, diamond, 8, 8, 8, 8, 8, 8},
{diamond, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8,8, diamond, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, diamond, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, diamond, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
}
,{
//10:gold
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8,8, 8, gold,gold, 8, 8, 8},
{8, 8, gold, gold, 8, 8, 8, 8, 8, 8},
{gold, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8,8, gold, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, gold, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, gold, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
},
{//11、木板
{14,14,0,14,14,14,0,14,14,14},
{14,14,0,14,14,14,0,14,14,14},
{14,14,0,14,14,14,0,14,14,14},
{14,14,0,14,14,14,0,14,14,14},
{14,14,0,14,14,14,0,14,14,14},
{14,14,0,14,14,14,0,14,14,14},
{14,14,0,14,14,14,0,14,14,14},
{14,14,0,14,14,14,0,14,14,14},
{14,14,0,14,14,14,0,14,14,14},
{14,14,0,14,14,14,0,14,14,14},
},{//12、工作台
{15,15,15,15,15,15,15,15,15,15},
{0,0,0,0,0,0,0,0,0,0},
{0,14,14,14,14,14,14,14,14,0},
{0,0,0,0,0,0,0,0,0,0},
{15,0,14,0,15,15,0,14,0,15},
{15,0,14,0,15,15,0,14,0,15},
{15,0,14,0,15,15,0,14,0,15},
{15,0,14,0,15,15,0,14,0,15},
{15,0,14,0,15,15,0,14,0,15},
{15,0,0,0,15,15,0,0,0,15},
}
,{
//13:煤炭
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8,8, 8, 0,0, 8, 8, 8},
{8, 8, 0, 0, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8,8, 0, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 0, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 0, 8, 8, 8},
{8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
},{
//14:钻块
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}
,{
//15:熔炉
{0, 0,0,0, 0, 0, 0, 0, 0, 0},
{0, 8,8,8, 8, 8, 8, 8, 8, 0},
{0, 8,8,8, 8, 8, 8, 8, 8, 0},
{0, 8,8,8, 8, 8, 8, 8, 8, 0},
{0, 0,0,0, 0, 0, 0, 0, 0, 0},
{0, 8,8,8, 8, 8, 8, 8, 8, 0},
{0, 8,8,0, 0, 0, 0, 8, 8, 0},
{0, 8,8,0, 8, 8,0, 8, 8, 0},
{0, 8,8,0, 8, 8, 0, 8, 8, 0},
{0, 0,0,0, 0, 0, 0, 0,0, 0}
},{
//16:铁锭
{15,15,15,15,15,15,15,15,15,15},
{15,15,15,15,15,15,15,15,15,15},
{ 0, 0, 0, 0, 0, 0, 0, 0,15,15},
{ 0, 0, 7, 7, 7, 7, 7, 7, 0,15},
{ 0, 7, 0, 0, 0, 0, 0, 0, 0, 0},
{15, 0, 0, 7, 7, 7, 7, 7, 7, 0},
{15,15, 0, 0, 0, 0, 0, 0, 0, 0},
{15,15,15,15,15,15,15,15,15,15},
{15,15,15,15,15,15,15,15,15,15},
{15,15,15,15,15,15,15,15,15,15}
},{
//17:金锭
{15,15,15,15,15,15,15,15,15,15},
{15,15,15,15,15,15,15,15,15,15},
{ 0, 0, 0, 0, 0, 0, 0, 0,15,15},
{ 0, 0, 6, 6, 6, 6, 6, 6, 0,15},
{ 0, 6, 0, 0, 0, 0, 0, 0, 0, 0},
{15, 0, 0, 6, 6, 6, 6, 6, 6, 0},
{15,15, 0, 0, 0, 0, 0, 0, 0, 0},
{15,15,15,15,15,15,15,15,15,15},
{15,15,15,15,15,15,15,15,15,15},
{15,15,15,15,15,15,15,15,15,15}
},{
//18:铁块
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 7, 7, 7, 7, 7, 7, 7, 7, 0},
{0, 7, 7, 7, 7, 7, 7, 7, 7, 0},
{0, 7, 7, 7, 7, 7, 7, 7, 7, 0},
{0, 7, 7, 7, 7, 7, 7, 7, 7, 0},
{0, 7, 7, 7, 7, 7, 7, 7, 7, 0},
{0, 7, 7, 7, 7, 7, 7, 7, 7, 0},
{0, 7, 7, 7, 7, 7, 7, 7, 7, 0},
{0, 7, 7, 7, 7, 7, 7, 7, 7, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
},{
//19:金块
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 6, 6, 6, 6, 6, 6, 6, 6, 0},
{0, 6, 6, 6, 6, 6, 6, 6, 6, 0},
{0, 6, 6, 6, 6, 6, 6, 6, 6, 0},
{0, 6, 6, 6, 6, 6, 6, 6, 6, 0},
{0, 6, 6, 6, 6, 6, 6, 6, 6, 0},
{0, 6, 6, 6, 6, 6, 6, 6, 6, 0},
{0, 6, 6, 6, 6, 6, 6, 6, 6, 0},
{0, 6, 6, 6, 6, 6, 6, 6, 6, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}
};
int pLus[10][10]{
{15,15,15,15,0,0,15,15,15,15},
{15,15,15,15,0,0,15,15,15,15},
{15,15,15,15,0,0,15,15,15,15},
{15,15,15,15,0,0,15,15,15,15},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{15,15,15,15,0,0,15,15,15,15},
{15,15,15,15,0,0,15,15,15,15},
{15,15,15,15,0,0,15,15,15,15},
{15,15,15,15,0,0,15,15,15,15}
};
int eq[10][10]{
{15,15,15,15,15,15,15,15,15,15},
{15,15,15,15,15,15,15,15,15,15},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{15,15,15,15,15,15,15,15,15,15},
{15,15,15,15,15,15,15,15,15,15},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{15,15,15,15,15,15,15,15,15,15},
{15,15,15,15,15,15,15,15,15,15}
};
int good[10][10]{
{15,15,15,15,15,15,15,15,15,15},
{15,15,15,15,15,15,15,15,15,2},
{15,15,15,15,15,15,15,15,2,15},
{15,15,15,15,15,15,15,2,15,15},
{15,15,15,15,15,15,2,15,15,15},
{15,2,15,15,15,2,15,15,15,15},
{15,15,2,15,2,15,15,15,15,15},
{15,15,15,2,15,15,15,15,15,15},
{15,15,15,15,15,15,15,15,15,15},
{15,15,15,15,15,15,15,15,15,15}
};
int bad[10][10]{
{15,15,15,15,15,15,15,15,15,15},
{15,15,15,15,15,15,15,15,15,15},
{15,15,4,15,15,15,4,15,15,15},
{15,15,15,4,15,4,15,15,15,15},
{15,15,15,15,4,15,15,15,15,15},
{15,15,15,4,15,4,15,15,15,15},
{15,15,4,15,15,15,4,15,15,15},
{15,15,15,15,15,15,15,15,15,15},
{15,15,15,15,15,15,15,15,15,15},
{15,15,15,15,15,15,15,15,15,15}
};
int nums[10][10][5]{
{
{7,7,7,7,7},
{7,0,0,0,7},
{7,0,7,0,7},
{7,0,7,0,7},
{7,0,7,0,7},
{7,0,7,0,7},
{7,0,7,0,7},
{7,0,7,0,7},
{7,0,0,0,7},
{7,7,7,7,7}
},
{
{7,7,7,7,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,7,7}
},
{
{7,7,7,7,7},
{7,0,0,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,0,0,0,7},
{7,0,7,7,7},
{7,0,7,7,7},
{7,0,7,7,7},
{7,0,0,0,7},
{7,7,7,7,7}
},
{
{7,7,7,7,7},
{7,0,0,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,0,0,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,0,0,0,7},
{7,7,7,7,7}
},
{
{7,7,7,7,7},
{7,0,7,0,7},
{7,0,7,0,7},
{7,0,7,0,7},
{7,0,0,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,7,7}
},
{
{7,7,7,7,7},
{7,0,0,0,7},
{7,0,7,7,7},
{7,0,7,7,7},
{7,0,0,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,0,0,0,7},
{7,7,7,7,7}
},
{
{7,7,7,7,7},
{7,0,0,0,7},
{7,0,7,7,7},
{7,0,7,7,7},
{7,0,0,0,7},
{7,0,7,0,7},
{7,0,7,0,7},
{7,0,7,0,7},
{7,0,0,0,7},
{7,7,7,7,7}
},
{
{7,7,7,7,7},
{7,0,0,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,7,7}
},
{
{7,7,7,7,7},
{7,0,0,0,7},
{7,0,7,0,7},
{7,0,7,0,7},
{7,0,0,0,7},
{7,0,7,0,7},
{7,0,7,0,7},
{7,0,7,0,7},
{7,0,0,0,7},
{7,7,7,7,7}
},
{
{7,7,7,7,7},
{7,0,0,0,7},
{7,0,7,0,7},
{7,0,7,0,7},
{7,0,0,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,7,7,0,7},
{7,0,0,0,7},
{7,7,7,7,7}
}
};
int player[20][10] = {
{15, 15, 15, 15, 15, 15, 15, 15, 15, 15},
{15, 15, 0, 0, 0, 0, 0, 0, 15, 15},
{15, 15, 0, 0, 0, 0, 0, 0, 15, 15},
{15, 15, 14, 14, 0, 0, 0, 0, 15, 15},
{15, 15, 14, 14, 14, 14, 0, 0, 15, 15},
{15, 15, 14, 14, 14, 14, 14, 14, 15, 15},
{15, 15, 14, 14, 14, 14, 14, 14, 15, 15},
{15, 15, 15, 3, 3, 3, 3, 15, 15, 15},
{15, 15, 15, 3, 3, 3, 3, 15, 15, 15},
{6, 3, 3, 3, 3, 3, 3, 15, 15, 15},
{6, 3, 3, 3, 3, 3, 3, 15, 15, 15},
{15, 15, 15, 3, 3, 3, 3, 15, 15, 15},
{15, 15, 15, 3, 3, 3, 3, 15, 15, 15},
{15, 15, 15, 1, 1, 1, 3, 15, 15, 15},
{15, 15, 15, 1, 1, 1, 1, 15, 15, 15},
{15, 15, 15, 1, 1, 1, 1, 15, 15, 15},
{15, 15, 15, 1, 1, 1, 1, 15, 15, 15},
{15, 15, 15, 1, 1, 1, 1, 15, 15, 15},
{15, 15, 15, 1, 1, 1, 1, 15, 15, 15},
{15, 15, 15, 8, 8, 8, 8, 15, 15, 15},
};
ofstream wlog("log.txt"); //日志输出
struct obj{
int id,num;
};
vector<obj>bag;
int pointer1,pointer2,pointer3;
//程序函数
int WDOUBLE = 0;
void hello() { //首次运行设置
nofastedit();
cursor(false);
SetConsoleActiveScreenBuffer(hsout);
swrite("你好,欢迎使用SUPERCRAFT。\n");
swrite("在开始之前,我们需要进行一些设置。\n");
swrite("[按任意键继续]");
getch();
system("cls");
swrite("在显示的两个正方形中,选择较为规整的一个\n");
swrite("[按任意键继续]");
getch();
system("cls");
SetConsoleActiveScreenBuffer(hout);
setfontsize(4, 4);
for (int i = 1; i <= 10; i++) {
WORD w[1005];
int pos = 0;
COORD coord = {1, i};
for (int j = 1; j <= 10; j++) {
w[pos++] = get_font(15, 15);
}
WriteConsoleOutputAttribute(hout, w, pos, coord, &written);
}
for (int i = 1; i <= 10; i++) {
WORD w[1005];
int pos = 0;
COORD coord = {13, i};
for (int j = 1; j <= 10; j++) {
w[pos++] = get_font(15, 15);
w[pos++] = get_font(15, 15);
}
WriteConsoleOutputAttribute(hout, w, pos, coord, &written);
}
getch();
system("cls");
SetConsoleActiveScreenBuffer(hsout);
swrite("哪一个正方形是最规整的?\n");
swrite("1.左边的 2.右边的");
reinput:
int ipt = getch();
if (ipt == '1') {
WDOUBLE = 0;
} else if (ipt == '2') {
WDOUBLE = 1;
} else {
goto reinput;
}
system("cls");
swrite("按+/-调整窗口大小,F键确定\n");
swrite("请保持白色方块为正方形\n[按任意键继续]");
getch();
SetConsoleActiveScreenBuffer(hout);
if (WDOUBLE == 0) {
system("mode con:cols=200 lines=100");
} else {
system("mode con:cols=400 lines=100");
}
if (WDOUBLE == 0) {
for (int i = 1; i <= 10; i++) {
WORD w[1005];
int pos = 0;
COORD coord = {1, i};
for (int j = 1; j <= 10; j++) {
w[pos++] = get_font(4, 4);
}
WriteConsoleOutputAttribute(hout, w, pos, coord, &written);
}
} else {
for (int i = 1; i <= 10; i++) {
WORD w[1005];
int pos = 0;
COORD coord = {1, i};
for (int j = 1; j <= 10; j++) {
w[pos++] = get_font(4,4);
w[pos++] = get_font(4, 4);
}
WriteConsoleOutputAttribute(hout, w, pos, coord, &written);
}
}
int sizes = 4;
while (1) {
int ipt = getch();
if (ipt == '+' || ipt == '=') {
sizes++;
setfontsize(sizes, sizes);
if (WDOUBLE == 0) {
system("mode con:cols=200 lines=100");
} else {
system("mode con:cols=400 lines=100");
}
}
if (ipt == '-' || ipt == '_') {
sizes--;
if (sizes < 1) {
sizes = 1;
}
setfontsize(sizes, sizes);
if (WDOUBLE == 0) {
system("mode con:cols=200 lines=100");
} else {
system("mode con:cols=400 lines=100");
}
}
if (WDOUBLE == 0) {
for (int i = 1; i <= 10; i++) {
WORD w[1005];
int pos = 0;
COORD coord = {1, i};
for (int j = 1; j <= 10; j++) {
w[pos++] = get_font(15, 15);
}
WriteConsoleOutputAttribute(hout, w, pos, coord, &written);
}
} else {
for (int i = 1; i <= 10; i++) {
WORD w[1005];
int pos = 0;
COORD coord = {1, i};
for (int j = 1; j <= 10; j++) {
w[pos++] = get_font(15, 15);
w[pos++] = get_font(15, 15);
}
WriteConsoleOutputAttribute(hout, w, pos, coord, &written);
}
}
if (ipt == 'f' || ipt == 'F') {
break;
}
}
SetConsoleActiveScreenBuffer(hsout);
system("cls");
ofstream sout("sets");
sout << WDOUBLE << " " << sizes;
sout.close();
swrite("谢谢!\n设置已保存,以后将不会出现此窗口。\n");
swrite("如果对此次设定不满意,可以删除sets文件以重新设置\n[按任意键继续]");
getch();
SetConsoleActiveScreenBuffer(hout);
}
int world[5005][256];
int X = 25000, Y = 1280, LR = 0, FPS = 60; //玩家位置
int output[201][121]; //输出缓存
void sendprint() { //绘制控制台
WORD col[24005] = {};
int pos = 0;
//将二维数组存储到一维内
for (int i = 1; i <= 120; i++) {
for (int j = 1; j <= 200; j++) {
col[pos] = get_font(output[j][i], output[j][i]);
pos++;
}
}
writefont(col, 24000);
}
bool unLight[5005][256];
void sendprint_double() { //绘制控制台
WORD col[48005] = {};
int pos = 0;
//将二维数组存储到一维内
for (int i = 1; i <= 120; i++) {
for (int j = 1; j <= 200; j++) {
col[pos] = get_font(output[j][i], output[j][i]);
pos++;
col[pos] = get_font(output[j][i], output[j][i]);
pos++;
}
}
writefont(col, 48000);
}
//世界
int dx[4]{0,0,-1,1},dy[4]{1,-1,0,0};
map<int,bool>unblock;
struct craft{
int num1,id1,num2,id2,num3,id3,num4,id4;
};
vector<craft>crafta,craftb,craftc;
int mode=0;
void init();
void render_block(int y,int x,int id){
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
output[x+i][y+j]=blocks[id][j][i];
}
}
}
void render_plus(int y,int x,int black=0,int white=15){
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
output[x+i][y+j]=(pLus[j][i]?white:black);
}
}
}
void render_eq(int y,int x,int black=0,int white=15){
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
output[x+i][y+j]=(eq[j][i]?white:black);
}
}
}
void render_number(int y,int x,int num,int black=0,int
white=15){
for(int i=0;i<5;i++){
for(int j=0;j<10;j++){
int k=nums[num/10][j][i];
output[x+i][y+j]=(k?white:black);
}
}
for(int i=0;i<5;i++){
for(int j=0;j<10;j++){
int k=nums[num%10][j][i];
output[x+i+5][y+j]=(k?white:black);
}
}
}
void render_good(int y,int x){
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
output[x+i][y+j]=good[j][i];
}
}
}
void render_bad(int y,int x){
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
output[x+i][y+j]=bad[j][i];
}
}
}
bool check(craft a){
int s1=0,s2=0,s3=0;
for(int i=0;i<bag.size();i++){
if(bag[i].id==a.id1){
s1+=bag[i].num;
}
if(bag[i].id==a.id2){
s2+=bag[i].num;
}
if(bag[i].id==a.id3){
s3+=bag[i].num;
}
}
if((s1>=a.num1||a.id1==0)&&(s2>=a.num2||a.id2==0)&&(
s3>=a.num3||a.id3==0)){
return 1;
}
return 0;
}
void Craft(craft cr){
int s1=cr.num1,s2=cr.num2,s3=cr.num3;
for(int i=0;i<bag.size();i++){
if(bag[i].id==cr.id1&&s1!=0){
if(bag[i].num>=s1){
bag[i].num-=s1;
}else{
s1-=bag[i].num;
bag[i].num=0;
}
}
if(bag[i].id==cr.id2&&s2!=0){
if(bag[i].num>=s2){
bag[i].num-=s2;
}else{
s2-=bag[i].num;
bag[i].num=0;
}
}
if(bag[i].id==cr.id3&&s3!=0){
if(bag[i].num>=s3){
bag[i].num-=s3;
}else{
s3-=bag[i].num;
bag[i].num=0;
}
}
}
for(int i=0;i<bag.size();i++){
if(bag[i].num==0){
bag.erase(bag.begin()+i);
i--;
}
}
obj o;
o.num=cr.num4;
o.id=cr.id4;
for(int i=0;i<bag.size();i++){
if(o.id==bag[i].id){
bag[i].num+=o.num;
return;
}
}
bag.push_back(o);
}
bool check_block_unlight(int m){
return m==3||m==4||m==8||m==9||m==10||m==13;
}
bool check_light(int x,int y){
for(int i=0;i<=3;i++){
if(unLight[x+dx[i]][y+dy[i]]==0&&!check_block_unlight(
world[x+dx[i]][y+dy[i]])){
return 1;
}
}
return 0;
}
void console() { //设置控制台
system("title SUPERCRAFT");
system("chcp 936");
system("cls");
hsout = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, 1, NULL);
if (!access("sets")) { //不存在
hello();
}
cout<<"请输入存档名:(输入none重新建档)";
cin>>xs;
if(xs=="none"){
cout<<"请输入档名:"
;cin>>xs;
generation(-1);
}else{
ifstream sin(xs.c_str());
for(int i=1;i<=5000;i++){
for(int j=1;j<=256;j++){
sin>>world[i][j];
}
}
for(int i=1;i<=5000;i++){
for(int j=1;j<=256;j++){
int x;
sin>>unLight[i][j];//=bool(x);
}
}
sin>>X>>Y;
int t,t2;
while(sin>>t>>t2){
bag.push_back({t,t2});
}
}
nofastedit(); //关闭快速输入
cursor(false); //关闭光标显示
ifstream sin("sets");
int sizes;
sin >> WDOUBLE >> sizes; //读入设置
sin.close();
setfontsize(sizes, sizes);
if (WDOUBLE == 0) {
system("mode con:cols=200 lines=120");
} else {
system("mode con:cols=400 lines=120");
}
}
void render() { //软件渲染器
if(mode==0){
int x_left = X / 10 - 9,
x_right = (X % 10 == 0) ? (X / 10 + 10) :
(X / 10 + 11); //计算需要渲染的左边线和右边线
int y_left = (Y % 10 == 0) ? (Y / 10 - 5) :
(Y / 10 - 6), y_right = Y / 10 + 5; //计算需要渲染的上边线和下边线
int x_more = X % 10, y_more = Y % 10; //计算多出的部分
int x_pos = 1, y_pos = 1; //渲染位置计算
//渲染世界
for (int i = x_left; i <= x_right; i++) {
y_pos = 1;
for (int j = y_right; j >= y_left; j--) {
for (int p_i = 0; p_i < 10; p_i++) {
for (int p_j = 0; p_j < 10; p_j++) {
if (x_pos + p_i - x_more < 0 ||
x_pos + p_i - x_more > 200 ||
y_pos - p_j + y_more < 0 ||
y_pos - p_j + y_more > 100) {
continue; //如果越界则跳过
}
if(check_light(i,j)){
unLight[i][j]=0;
output[x_pos + p_i - x_more][y_pos - p_j
+ y_more] = blocks[world[i][j]][9 - p_j
][p_i];
}else
output[x_pos + p_i - x_more][y_pos - p_j
+ y_more]=0;
}
}
y_pos += 10;
}
x_pos += 10;
}
//渲染玩家
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 20; j++) {
if (LR == 0) {
if (player[j][i] != 15) {
output[91 + i][36 + j] = player[j][i];
}
} else {
if (player[j][9 - i] != 15) {
output[91 + i][36 + j] = player[j][9 - i];
}
}
}
}
}
else if(mode==1){
for(int i=1;i<=200;i++){
for(int j=1;j<=100;j++){
output[i][j]=15;
}
}
for(int i=pointer3;i<crafta.size()&&i<pointer3+10;i++){
int k=i-pointer3;
render_number(k*11+1,0,crafta[i].num1);
render_block(k*11+1,10,crafta[i].id1);
render_plus(k*11+1,20);
render_number(k*11+1,30,crafta[i].num2);
render_block(k*11+1,40,crafta[i].id2);
render_plus(k*11+1,50);
render_number(k*11+1,60,crafta[i].num3);
render_block(k*11+1,70,crafta[i].id3);
render_eq(k*11+1,80);
render_number(k*11+1,90,crafta[i].num4);
render_block(k*11+1,100,crafta[i].id4);
if(check(crafta[i])){
render_good(k*11+1,120);
}else{
render_bad(k*11+1,120);
}
}
}else if(mode==2){
for(int i=1;i<=200;i++){
for(int j=1;j<=100;j++){
output[i][j]=15;
}
}
for(int i=pointer3;i<craftb.size()&&i<pointer3+10;i++){
int k=i-pointer3;
render_number(k*11+1,0,craftb[i].num1);
render_block(k*11+1,10,craftb[i].id1);
render_plus(k*11+1,20);
render_number(k*11+1,30,craftb[i].num2);
render_block(k*11+1,40,craftb[i].id2);
render_plus(k*11+1,50);
render_number(k*11+1,60,craftb[i].num3);
render_block(k*11+1,70,craftb[i].id3);
render_eq(k*11+1,80);
render_number(k*11+1,90,craftb[i].num4);
render_block(k*11+1,100,craftb[i].id4);
if(check(craftb[i])){
render_good(k*11+1,120);
}else{
render_bad(k*11+1,120);
}
}
}else if(mode==3){
for(int i=1;i<=200;i++){
for(int j=1;j<=100;j++){
output[i][j]=15;
}
}
for(int i=pointer3;i<craftc.size()&&i<pointer3+10;i++){
int k=i-pointer3;
render_number(k*11+1,0,craftc[i].num1);
render_block(k*11+1,10,craftc[i].id1);
render_plus(k*11+1,20);
render_number(k*11+1,30,craftc[i].num2);
render_block(k*11+1,40,craftc[i].id2);
render_plus(k*11+1,50);
render_number(k*11+1,60,craftc[i].num3);
render_block(k*11+1,70,craftc[i].id3);
render_eq(k*11+1,80);
render_number(k*11+1,90,craftc[i].num4);
render_block(k*11+1,100,craftc[i].id4);
if(check(craftc[i])){
render_good(k*11+1,120);
}else{
render_bad(k*11+1,120);
}
}
}
int colour=(jianzao?9:12);
for(int i=0;i+pointer2*20<bag.size();i++){
for(int j=0;j<5;j++){
for(int k=0;k<10;k++){
if(pointer1!=i)
output[i*10+1+j][111+k]=nums[bag[i
+pointer2*20].num%100/10][k][j];
else
output[i*10+1+j][111+k]=((nums[bag[i+
pointer2*20].num%100/10][k][j]==0)?colour:7);
}
}
for(int j=0;j<5;j++){
for(int k=0;k<10;k++){
if(pointer1!=i)
output[i*10+6+j][111+k]=nums[bag[i+
pointer2*20].num%10][k][j];
else
output[i*10+6+j][111+k]=((nums[bag[i+
pointer2*20].num%10][k][j]==0)?colour:7);
}
}
}
for(int i=0;i+pointer2*20<bag.size();i++){
for(int j=0;j<10;j++){
for(int k=0;k<10;k++){
output[i*10+1+j][101+k]=blocks[bag[i+pointer2*20
].id][k][j];
}
}
}
for(int i=max((int)bag.size()-pointer2*20,0);i<=20;i++){
for(int j=0;j<10;j++){
for(int k=0;k<20;k++){
output[i*10+1+j][101+k]=0;
}
}
}
}
void dfs_dong(int st,int x,int y){
if(x<=2||y<=2||x>=4900||world[x][y]==0||st==0){
return ;
}
world[x][y]=0;
for(int i=0;i<3;i++){
if(rand(1,3)>1){
dfs_dong(st-1,x+dx[i],y+dy[i]);
}
}
}
void generation(int seed) {
//生成种子
if (seed == -1) {
srand(time(0));
srand(rand() + time(0));
seed = rand();
}
srand(seed);
//生成空气
for (int i = 0; i < 5000; i++) {
for (int j = 1; j < 256; j++) {
world[i][j] = 0;
}
}
//生成基本地形
int grass = rand(50, 80);
int higher = rand(1, 3);
int trend = 1, stop_sum = 1;
bool biome = rand(0, 1);
int tree;
for (int i = 0; i < 5000; i++) {
world[i][0] = 4; //基岩
for (int j = 1; j < grass - 3; j++) {
unLight[i][j]=1;
if(i<80||i>4920){
world[i][j]=4;
continue;
}
if(j==14){
if(rand(1,14)==1){
world[i][j]=9;
continue;
}
}
if(rand(1,1000)==1){
dfs_dong(rand(3,5),i-1,j);
}
if(rand(1,6000)==1){
dfs_dong(rand(12,15),i-1,j);
}
if(rand(1,20000)==1){
dfs_dong(rand(20,30),i-1,j);
}
if(rand(1,30)!=1){
world[i][j]=3;
}else if(rand(1,5)!=1){
world[i][j]=8+rand(0,1)*5;
}else if(rand(1,5)==3&&j<20){
world[i][j]=9;
}else{
world[i][j]=10;
}
}
for (int j = grass - 3; j < grass; j++) {
world[i][j] = 2; //泥土
}
world[i][grass] = 1;
if(tree==0&&(world[i][grass]!=5&&grass>63))
tree=int(!rand(0,20))*5;
else
tree=0;
if(tree!=0&&i>100&&i<4900){
for(int j=grass+1;j<grass+tree;j++){
world[i][j]=6;
if(j==grass+tree-1){
for(int k=-2;k<=2;k++){
if(world[i+k][j]==0){
world[i+k][j]=7;
}
}
for(int k=-2;k<=2;k++){
if(world[i+k][j+1]==0){
world[i+k][j+1]=7;
}
}
for(int k=-1;k<=1;k++){
if(world[i+k][j+2]==0){
world[i+k][j+2]=7;
}
}
}
}
}
if (biome) { //生成下一个草方块高度
if (rand(0, 7) == 3) {
grass += trend;
stop_sum = 1;
} else {
stop_sum++;
}
} else {
if (rand(0, nozero(3 - stop_sum)) == 0) {
grass += trend * higher;
stop_sum = 1;
} else {
stop_sum++;
}
}
//随机更新高度
if (rand(0, 1) == 1) {
higher++;
} else {
higher--;
}
if (rand(0, 40) == 10) {
trend *= -1;
}
if (rand(0, 100) == 50) {
biome = !biome;
}
//限制范围
if (grass > 120) {
grass = 120;
}
if (grass < 40) {
grass = 40;
}
if (higher > 2) {
higher = 2;
}
if (higher < 1) {
higher = 1;
}
if(grass<=55){
if(rand(1,3)==3){
trend=1;
}
}
}
}
void *printmain(void *arg) {
clock_t st, tmp;
int sum = 0, fps = -1;
char t[1005];
st = clock();
while (1) {
render(); //软件渲染
if (WDOUBLE == 0) { //发送渲染
sendprint();
} else {
sendprint_double();
}
sum++; //记录渲染个数
sprintf(t, "SUPERCRAFT (X:%.1f,Y:%.1f,FPS:%d)", X * 1.0 / 10.0, Y * 1.0 / 10.0, fps); //输出FPS,坐标
tmp = clock();
if (tmp - st >= 1000) { //计算FPS
fps = sum / ((tmp - st) / 1000.0);
sum = 0;
st = tmp;
}
SetConsoleTitleA(t); //输出FPS
}
}
bool canin(int x) { //判断人能否进入方块
return x == 0 || x == 5||x==6||x==7;
}
bool _canin(int x,int y){
return canin(world[x/10][y/10]);
}
void inita(){
craft now_craft;
now_craft.id1=6; now_craft.num1=1;
now_craft.id2=0; now_craft.num2=0;
now_craft.id3=0; now_craft.num3=0;
now_craft.id4=11; now_craft.num4=4;
crafta.push_back(now_craft);
now_craft.id1=11; now_craft.num1=4;
now_craft.id2=0; now_craft.num2=0;
now_craft.id3=0; now_craft.num3=0;
now_craft.id4=12; now_craft.num4=1;
crafta.push_back(now_craft);
}
void initb(){
craft now_craft;
now_craft.id1=6; now_craft.num1=1;
now_craft.id2=0; now_craft.num2=0;
now_craft.id3=0; now_craft.num3=0;
now_craft.id4=11; now_craft.num4=4;
craftb.push_back(now_craft);
now_craft.id1=11; now_craft.num1=4;
now_craft.id2=0; now_craft.num2=0;
now_craft.id3=0; now_craft.num3=0;
now_craft.id4=12; now_craft.num4=1;
craftb.push_back(now_craft);
now_craft.id1=9; now_craft.num1=9;
now_craft.id2=0; now_craft.num2=0;
now_craft.id3=0; now_craft.num3=0;
now_craft.id4=14; now_craft.num4=1;
craftb.push_back(now_craft);
now_craft.id1=3; now_craft.num1=8;
now_craft.id2=0; now_craft.num2=0;
now_craft.id3=0; now_craft.num3=0;
now_craft.id4=15; now_craft.num4=1;
craftb.push_back(now_craft);
now_craft.id1=16; now_craft.num1=9;
now_craft.id2=0; now_craft.num2=0;
now_craft.id3=0; now_craft.num3=0;
now_craft.id4=18; now_craft.num4=1;
craftb.push_back(now_craft);
now_craft.id1=17; now_craft.num1=9;
now_craft.id2=0; now_craft.num2=0;
now_craft.id3=0; now_craft.num3=0;
now_craft.id4=19; now_craft.num4=1;
craftb.push_back(now_craft);
}
void initc(){
craft now_craft;
now_craft.id1=8; now_craft.num1=1;
now_craft.id2=11; now_craft.num2=1;
now_craft.id3=0; now_craft.num3=0;
now_craft.id4=16; now_craft.num4=1;
craftc.push_back(now_craft);
now_craft.id1=10; now_craft.num1=1;
now_craft.id2=11; now_craft.num2=1;
now_craft.id3=0; now_craft.num3=0;
now_craft.id4=17; now_craft.num4=1;
craftc.push_back(now_craft);
now_craft.id1=8; now_craft.num1=6;
now_craft.id2=13; now_craft.num2=1;
now_craft.id3=0; now_craft.num3=0;
now_craft.id4=16; now_craft.num4=6;
craftc.push_back(now_craft);
now_craft.id1=10; now_craft.num1=6;
now_craft.id2=13; now_craft.num2=1;
now_craft.id3=0; now_craft.num3=0;
now_craft.id4=17; now_craft.num4=6;
craftc.push_back(now_craft);
}
int main() {
inita();
initb();
initc();
console(); //控制台设置
pthread_create(NULL, NULL, printmain, NULL); //创建渲染线程
//生成世界
int jumps = 0;
int cnt[129]{0};
while (1) { //主循环:游戏刻
if(mode==0){//世界部分
{//行动部分
if (keydown('A') &&_canin(X-1,Y-4)&&_canin(X-1,Y+6)) {
X--; //向左走
LR = 0;
}
if (keydown('D') && _canin(X+10,Y-4)&&_canin(X+10,Y+6)) {
X++; //向右走
LR = 1;
}
if (keydown('W') &&!(_canin(X,Y-6)&&_canin(X+9,Y-6))) {
jumps = 18; //跳跃(判断)
}
if(jumps>0||_canin(X,Y-5)&&_canin(X+9,Y-5)){
if(jumps>0)
for(int i=1;i<=jumps/6;Y++,i++){
if(!(_canin(X,Y+14)&&_canin(X+9,Y+14))){
Y-=3;
jumps=0;
break;
}
}
else{
for(int i=1;i<=jumps/-6;Y--,i++){
if(!(_canin(X,Y-5)&&_canin(X+9,Y-5))){
Y++;
break;
}
}
}
while(!(_canin(X,Y-5)&&_canin(X+9,Y-5))){
Y++;
}
jumps--;
} else {
jumps=0;
}
}
{//挖掘测试
bool flag=0;
int*m;
if(keydown(' ')){
cnt[' ']++;
if(cnt[' ']%9==8)
jianzao=!jianzao;
}
if(keydown('H')){
cnt['h']++;
if(cnt['h']%5==2){
m=&world[(X+15)/10][Y/10];
flag=1;
}
}
if(keydown('Y')){
cnt['y']++;
if(cnt['y']%5==2){
m=&world[(X+15)/10][(Y+10)/10]; flag=1;}
}
if(keydown('F')){
cnt['f']++;
if(cnt['f']%5==2){
m=&world[(X-5)/10][Y/10];flag=1;}
}
if(keydown('R')){
cnt['r']++;
if(cnt['r']%5==2){
m=&world[(X-5)/10][(Y+10)/10];flag=1;}
}
if(keydown('T')){
cnt['t']++;
if(cnt['t']%5==2)
if(LR==0){
m=&world[X/10][(Y+20)/10];
flag=1;
}else{
m=&world[(X+9)/10][(Y+20)/10];
flag=1;
}
}
if(keydown('G')){
cnt['g']++;
if(cnt['g']%5==2)
if(LR==0){
m=&world[X/10][(Y-10)/10];
flag=1;
}else{
m=&world[(X+9)/10][(Y-10)/10];
flag=1;
}
}
if(flag==1){
int&k=*m;
if(k!=0&&k!=4&&!jianzao){
for(int i=0;i<bag.size();i++){
if(bag[i].id==k){
bag[i].num++;
goto gt;
}
}
bag.push_back({k,1});
gt:;
k=0;
}else if(k==0&&jianzao){
int p1=pointer1,p2=pointer2;
if(bag.size()>p2*20+p1){
k=bag[p2*20+p1].id;
bag[p2*20+p1].num--;
if(bag[p2*20+p1].num==0){
bag.erase(bag.begin()+p2*20+p1);
}
}
}
}
}
if(keydown('E')){
cnt['e']++;
if(cnt['e']%7==6){
cnt['e']=0;
if(bag[pointer1+pointer2*20].id!=12&&
bag[pointer1+pointer2*20].id!=15){
pointer3=0;
mode=1;
}else if(bag[pointer1+pointer2*20].id==12){
pointer3=0;
mode=2;
}else if(bag[pointer1+pointer2*20].id==15){
pointer3=0;
mode=3;
}
}
}
}
else if(mode==1){//合成部分
if(keydown('E')){
cnt['e']++;
if(cnt['e']%7==6){
cnt['e']=0;
mode=0;
}
}
if(keydown(' ')){
cnt[' ']++;
if(cnt[' ']%9==8){
if(check(crafta[pointer3])){
Craft(crafta[pointer3]);
}
}
}
if(keydown('I')){
cnt['i']++;
if(cnt['i']%9==8){
pointer3--;
if(pointer3<0){
pointer3=0;
}
}
}
if(keydown('K')){
cnt['k']++;
if(cnt['k']%9==8){
pointer3++;
if(pointer3>=crafta.size()){
pointer3=crafta.size()-1;
}
}
}
}
else if(mode==2){//合成部分2
if(keydown('E')){
cnt['e']++;
if(cnt['e']%7==6){
cnt['e']=0;
mode=0;
}
}
if(keydown(' ')){
cnt[' ']++;
if(cnt[' ']%9==8){
if(check(craftb[pointer3])){
Craft(craftb[pointer3]);
}
}
}
if(keydown('I')){
cnt['i']++;
if(cnt['i']%9==8){
pointer3--;
if(pointer3<0){
pointer3=0;
}
}
}
if(keydown('K')){
cnt['k']++;
if(cnt['k']%9==8){
pointer3++;
if(pointer3>=craftb.size()){
pointer3=craftb.size()-1;
}
}
}
}else if(mode==3){//合成部分3
if(keydown('E')){
cnt['e']++;
if(cnt['e']%7==6){
cnt['e']=0;
mode=0;
}
}
if(keydown(' ')){
cnt[' ']++;
if(cnt[' ']%9==8){
if(check(craftc[pointer3])){
Craft(craftc[pointer3]);
}
}
}
if(keydown('I')){
cnt['i']++;
if(cnt['i']%9==8){
pointer3--;
if(pointer3<0){
pointer3=0;
}
}
}
if(keydown('K')){
cnt['k']++;
if(cnt['k']%9==8){
pointer3++;
if(pointer3>=craftc.size()){
pointer3=craftc.size()-1;
}
}
}
}
{//背包测试
if (keydown('O') ) {
cnt['o']++;
}
if (keydown('P') ) {
cnt['p']++;
}
if(cnt['p']%8==7){
pointer1++;
cnt['p']++;
if(pointer1>19){
pointer1=0;
pointer2++;
if(pointer2*20>=bag.size()){
pointer2=0;
pointer1=0;
}
}
}
if(cnt['o']%8==7){
cnt['o']++;
pointer1--;
if(pointer1<0){
pointer1=19;
pointer2--;
if(pointer2<0){
pointer2=0;
}
}
}
}
if(keydown('Z')){
ofstream fout(xs.c_str());
for(int i=1;i<=5000;i++){
for(int j=1;j<=256;j++){
fout<<world[i][j]<<" ";
}
}
for(int i=1;i<=5000;i++){
for(int j=1;j<=256;j++){
fout<<unLight[i][j]<<" ";
}
}
fout<<X<<" "<<Y<<" ";
for(int i=0;i<bag.size();i++){
fout<<bag[i].id<<" "<<bag[i].num<<" ";
}
return 0;
}
Sleep(10);
}
return 0;
}
WASD移动,RFGHYT挖掘或建造,E合成,IK移动合成表,合成模式按空格合成,一般模式按空格改变模式,红色是挖掘,蓝色是建造
Z退出并保存,OP移动指针,当指针指向工作台时按E键进入工作台,熔炉同理
有bug和我说,我也是个萌新
陈俊霖在2022-10-15 12:05:53追加了内容
顶
初级启示者
{
//6:原木
{0, 6, 6, 0, 6, 14, 6, 0, 6, 14},
{0, 14, 6, 0, 14, 0, 14, 6, 0, 14},
{0, 14, 6, 0, 14, 0, 14, 6, 0, 6},
{14, 6, 0, 14, 6, 0, 14, 6, 0, 14},
{6, 14, 6, 6, 14, 6, 6, 6, 0, 14},
{6, 0, 6, 0, 14, 6, 0, 6, 6, 14},
{6, 0, 14, 0, 14, 6, 0, 6, 14, 6},
{14, 0, 14, 6, 0, 14, 6, 0, 14, 0},
{14, 0, 6, 14, 0, 14, 6, 14, 14, 0},
{6, 14, 6, 14, 0, 6, 14, 6, 14, 0}
},
{
//7:树叶
{10, 2, 15, 10, 2, 15, 10, 2, 15, 10},
{10, 15, 10, 15, 15, 10, 15, 2, 10, 2},
{15, 10, 15, 10, 2, 15, 10, 15, 15, 10},
{10, 2, 15, 10, 15, 10, 15, 10, 2, 15},
{10, 15, 10, 15, 10, 15, 2, 2, 15, 10},
{2, 15, 2, 10, 2, 15, 10, 15, 10, 2},
{15, 10, 15, 10, 15, 10, 15, 2, 15, 10},
{10, 10, 10, 15, 10, 2, 15, 10, 2, 10},
{15, 2, 15, 10, 10, 15, 10, 2, 10, 15},
{10, 10, 10, 2, 15, 10, 15, 15, 10, 2}
},
初级启示者
//6:原木
{0, 6, 6, 0, 6, 14, 6, 0, 6, 14},
{0, 14, 6, 0, 14, 0, 14, 6, 0, 14},
{0, 14, 6, 0, 14, 0, 14, 6, 0, 6},
{14, 6, 0, 14, 6, 0, 14, 6, 0, 14},
{6, 14, 6, 6, 14, 6, 6, 6, 0, 14},
{6, 0, 6, 0, 14, 6, 0, 6, 6, 14},
{6, 0, 14, 0, 14, 6, 0, 6, 14, 6},