用户:
星星上的雪花查看:949 回复:9 评论:15 创建时间:2022-04-09T23:57:21
const h = 5; // 房间的高度
const sample = //房间的地形,可自定义更改
`\
墙墙墙墙墙墙墙墙墙墙墙墙墙墙
墙空空空空空空空空空空空空墙
墙空空空空空空空空空空空空墙
墙空空空空空空空空空墙墙墙墙
墙空空空空空空空空空门
墙空空空空空空空空空门
墙空空空空空空空空空墙墙墙墙
墙空空空空空空空空空空空空墙
墙空空空空空空空空空空空空墙
墙墙墙墙墙墙墙墙墙墙墙墙墙墙`;
const room = [];
const v = (x=0, y=0, z=0) => new Box3Vector3(x,y,z);
for(let index = 0; index < sample.split("\n").length; index ++)
{
const part = sample.split("\n")[index];
const build = [];
const high = 8;
for(const block of part)
{
if(block === "墙")
build.push([
"powder_blue",
v(index,high,build.length)
])
if(block === "空")
build.push([
"ice_brick",
v(index,high,build.length)
])
if(block === "门")
build.push([
"wood",
v(index,high,build.length)
])
};
room.push(build)
};
for(let x = 0; x < 255; x += 20)
for(let y = 0; y <= h; y ++)
for(let z = 0; z < 255; z += 20)
{
for(const a of room)
{
for(const b of a)
{
voxels.setVoxel(b[1].x+x,b[1].y+y,b[1].z+z,b[0])
}
}
};
星星上的雪花生成空心房间
{
const h = 5; // 房间的高度
const sample = //房间的地形,可自定义更改
`\
墙墙墙墙墙墙墙墙墙墙墙墙墙墙
墙空空空空空空空空空空空空墙
墙空空空空空空空空空空空空墙
墙空空空空空空空空空墙墙墙墙
墙空空空空空空空空空门
墙空空空空空空空空空门
墙空空空空空空空空空墙墙墙墙
墙空空空空空空空空空空空空墙
墙空空空空空空空空空空空空墙
墙墙墙墙墙墙墙墙墙墙墙墙墙墙`;
const room = [];
const v = (x=0, y=0, z=0) => new Box3Vector3(x,y,z);
for(let index = 0; index < sample.split("\n").length; index ++)
{
const part = sample.split("\n")[index];
const build = [];
const high = 8;
for(const block of part)
{
if(block === "墙")
build.push([
"powder_blue",
v(index,high,build.length)
])
if(block === "空")
build.push([
"air",
v(index,high,build.length)
])
if(block === "门")
build.push([
"wood",
v(index,high,build.length)
])
};
room.push(build)
};
for(let x = 0; x < 255; x += 20)
for(let y = 1; y <= h; y ++)
for(let z = 0; z < 255; z += 20)
{
for(const a of room)
{
for(const b of a)
{
voxels.setVoxel(b[1].x+x,b[1].y+y,b[1].z+z,b[0])
}
}
};
}点赞0
评论
速建代码有吗,这个会报错
先把代码复制到代码区里,点开始运行,然后马上点结束运行(用来保存代码),然后往控制台输“require("/文件名.js")”,如果放主文件里就是/index.js(建议除了速建代码以外不要放其它代码)
谢谢!!!!啦!!!
该账号已被封禁这也不难啊...
点赞0
评论
不就记录坐标然后后面跟速建差不多吗...
这里的核心技术是将文本转化为方块数据(比如说你可以用做个来做个Bad Apple)
(?)
阿这 这玩意不就是简单的if判断么...
你也可以在前面写一个对象 keys写自定义id value写方块名称到时候直接调用也彳亍
该账号已被封禁其实完全可以这样
let id={
'墙':'powder_blue',
'空':'air',
'门':'wood'
};
......
build.push([id[block],{x:index,y:high,z:build.length}]);
点赞0
评论
自己看 方便很多 不用写那么多if 你要实在想写就写switch简洁明了