猫史档案馆


【代码】灯塔

用户:呵呵0486呵呵0486查看:11 回复:10 评论:11 创建时间:2022-12-21T12:09:51


嗯首先我们先搞2个模型:灯和单元方块()

然后呢我们再在论坛里找几个大佬的代码()

function addlaser(start,end){
    const Quat = new Box3Quaternion(0,0,0,1);
    function addlaser(start,end){
        const distance = start.distance(end);
        const laser = world.createEntity({
            mesh: 'mesh/激光.vb',
            meshScale: [0.0625*distance,0.0625,0.0625],
            gravity: false,
            collides: false,
            fixed: true,
            position: start.lerp(end,0.5),
        })
        const d = start.sub(end);
        laser.meshOrientation = Quat.rotateX(Math.atan2(d.y,Math.sqrt(d.x**2+d.z**2))).rotateY(Math.atan2(d.z,d.x));
        const points = [];
        for(let i=0;i<distance;i+=0.1){
            points.push({
                lo: start.lerp(end,0.1*distance*i),
                hi: start.lerp(end,0.1*distance*i),
            })
        }
        world.onTick(()=>{
            points.forEach((e)=>{
                world.searchBox(e).forEach((e)=>{
                    if(e.isPlayer){
                        e.hurt(100);
                    }
                })
            })
        })
    }
}

(转自:Lolita 帖号:https://shequ.codemao.cn/community/387107)

 

const e1 = world.querySelector('#旋转实体');
world.onTick(async({tick})=>{
    const e2 = world.querySelectorAll('player')
    e2.forEach((e) =>{
        e1.position.y = e.position.y;
        e1.position.x = e.position.x + Math.cos(tick/5)*5
        e1.position.z = e.position.z + Math.sin(tick/5)*5
    })
})

(转自:浮生 帖号:https://shequ.codemao.cn/community/423452)

 

然后再稍微改一点点()

var pos = new Box3Vector3(0,0,0)/*这里面的数字填啥都行,没有影响*/
var tick = 0
setInterval(async() => {
    tick += 1
},50)

setInterval(async () => { 
    world.querySelectorAll('#地图内灯的名字').forEach((x) => {
        pos.x = x.position.x + Math.cos(tick / 喵0/*可以改 越大旋转越慢*/) * 104/*可以改 越大旋转的半径也越大*/
        pos.z = x.position.z + Math.sin(tick / 喵0/*可以改 越大旋转越慢*/) * 104/*可以改 越大旋转的半径也越大*/
        const light = world.createEntity({
            mesh:'mesh/单元方块.vb',
            meshScale:[1/16*x.position.distance(pos),1/16,1/16],
            position:x.position.lerp(pos,0.5),
            gravity:false,
            collides:false,
            fixed:true,
            meshEmissive:true
        })
        const d = x.position.sub(pos);
        light.meshOrientation = new Box3Quaternion(0,0,0,1).rotateX(Math.atan2(d.y,Math.sqrt(d.x**2+d.z**2))).rotateY(Math.atan2(d.z,d.x));
        sleep(110).then(async() => {
            light.destroy()
        })
    })
},100)

就行了()

 


回复

上一页1 页 / 共 1下一页
呵呵0486呵呵0486

效果图:

center_image

(不会搞动图())

点赞0


评论


小屑鹿小屑鹿

斜射激光!

点赞0


评论


小树同学小树同学

(#`㉨´)凸

点赞0


评论


屑怪盗屑怪盗

收藏

点赞0


评论


呵呵0486呵呵0486

再稍微改一点点甚至还能这样(?center_imagecenter_image

点赞1


评论


星语(虚空)星语(虚空)

hhc

点赞0


评论


guxia666guxia666

啊这需要这么难么()

点赞0


评论


馫龘飝鱻灥麤靐飍朤馫譶龘飝虪齺馫龘飝鱻灥麤靐飍朤馫譶龘飝虪齺

5555555555

点赞0


评论


一光之逆子一一光之逆子一

666666666666666666,太6了

 

点赞0


评论


呵呵0486呵呵0486

这么好的代码没人复制(((

点赞0


评论