猫史档案馆


【代码】猛鬼宿舍房间快速生成

用户:星星上的雪花星星上的雪花查看:15 回复: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])
        }
    }
};


回复

上一页1 页 / 共 1下一页
星星上的雪花星星上的雪花

生成空心房间

{
    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


评论


NinesirNinesir

猛鬼宿舍好像变成天上地下80座塔了

点赞0


评论


灵清帝王吃爆一切厕所灵清帝王吃爆一切厕所

收藏()

点赞0


评论


该账号已被封禁该账号已被封禁

这也不难啊...

点赞0


评论


该账号已被封禁该账号已被封禁

其实完全可以这样

let id={
    '墙':'powder_blue',
    '空':'air',
    '门':'wood'
};
......
build.push([id[block],{x:index,y:high,z:build.length}]);

点赞0


评论


梁桂琪梁桂琪

https://box3.codemao.cn/e/8c1df9d14aa3be73b026

点赞0


评论


学霸霸题学霸霸题

奇怪的知识增加了

点赞0


评论


alopdopsalopdops

dzd

 

点赞0


评论


不爱做跑酷不爱做跑酷

你是不是’借‘了战术兵团的地图代码?

emotion_编程猫_翻白眼

点赞0


评论