大家好,欢迎来到c++代码实现我的世界,第三集。
那么今天小编继续带领大家写我的世界。
上一集我们写了食物的代码,今天我们就来写世界的代码。
struct world{
};
这是x轴,横轴。
struct worldx{
struct worldy{
};
};
worldy是y轴,纵轴。
如果是使用32位编译器的观众,千万千万不要用三层结构体。因为……小编试过,反正不要用就是啦。
三层结构体:
struct worldx{
struct worldy{
struct worldz{
};
};
};
worldz就是第三个维度,x轴、y轴和z轴组成了我的世界的三维世界。
当然,我们是可以做二维世界。二维世界会在后面讲解。
栅栏和地毯可以放一起,所以:
struct worldx{
struct worldy{
struct worldz{
int block1,block2;
double high;
short light;
};
};
};
我们的x轴与z轴可以自己定义。小编在这里用的是510
struct worldx{
struct worldy{
struct worldz{
int block1,block2;
double high;
short light;
}z[510];
}y;
}x[510];
y轴的化,小编选的是400。目前正版我的世界也差不多是这个数字。
struct worldx{
struct worldy{
struct worldz{
int block1,block2;
double high;
short light;
}z[510];
}y[400];
}x[510];
当然,我的世界不只有主世界,还有下界,末地。
所以……
struct worldx{
struct worldy{
struct worldz{
int block1,block2;
double high;
short light;
}z[510];
}y[400];
}zhux[510],xiax[510],mox[510];
为了照顾我们32位编译器的观众,我们就稍加修改:
struct worldx{
struct worldy{
int z_block1[510];
int z_block2[510];
double z_high[510];
short z_light[510];
}y[400];
}zhux[510],xiax[510],mox[510];
目前,我们写了:
#include<bits/stdc++.h>
using namespace std;
struct worldx{
struct worldy{
int z_block1[510];
int z_block2[510];
double z_high[510];
short z_light[510];
}y[400];
}zhux[510],xiax[510],mox[510];
struct Food {
unsigned short bake_fool=0;
unsigned short bake_hart=0;
string En,Cn;
bool can_cook=0;
int th1,th2,th3,th4,th5,th6,th7,th8,th9;
}M_food[1000];
struct Blocks{
int thing1,thing2,thing3,thing4,thing5,thing6,thing7,thing8,thing9;//合成表
unsigned light=0;//光
string En,Cn;//名字
unsigned int fall=1;//掉落(模组)
bool xushi=1,gwxushi=1;//虚实
bool fall=0;//是否掉落
double high=1;//高度
unsigned get_tool=0;//工具
unsigned fumo_tool=0;//附魔(不需要==0)
double get_time=0;//获取时间
short bake_jump;//类粘液块方块
unsigned fangxiang=0;//放置方向
}zhu_B[100000],done[10000],last[5000];//主世界、下界、末地
下一期,我们将写工具的代码。
关注收藏不迷路,我们下期见。