Lv.1
在 【神岛创作节】音乐二创获奖名单出炉 中回复
二创模型的皮肤啥时候发啊imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E5%86%B7%E6%BC%A0.gif"alt="emotion_编程猫_冷漠" 等得花儿都谢了
2022-05-22T10:43:15 点赞:0
在 【box3】代码改良-球体代码 中回复
//稍加改良做出来的TNT破坏效果
async function sphere(vox, cx, cy, cz, radius){//参数分别是方块、x,y,z和圆的半径
let xend = cx+radius
let yend = cy+radius
let zend = cz+radius
for(let x=cx-radius;x<=xend;x++){
for(let y=cy-radius;y<=yend;y++){
for(let z=cz-radius;z<=zend;z++){
let dx = x-cx;
let dy = y-cy;
let dz = z-cz;
if(Math.round(Math.sqrt(dx*dx+dy*dy+dz*dz)) <= radius){
voxels.setVoxel(x,y,z,vox)
}
}}}
}
world.onPress(async({ button, entity, raycast }) => { //事件
if(button ==='action0'){
const ball =world.createEntity({//放个模型
mesh:"mesh/tnt.vb",
collides:true,
meshScale:[0.06,0.06,0.06],
position:[entity.position.x+raycast.direction.x, entity.position.y+raycast.direction.y, entity.position.z+raycast.direction.z],
})
ball.onVoxelContact(({ x, y, z, voxel }) => {//TNT碰到了方块
sphere('air',ball.position.x,ball.position.y,ball.position.z,3)//造一个空气球
ball.destroy()//删除TNT
});
ball.velocity.x += raycast.direction.x*2; ball.velocity.y += raycast.direction.y*2; ball.velocity.z += raycast.direction.z*2;
}
})2022-05-22T19:16:11 点赞:1
在 火力翻盘教程!(传奇勿喷) 中回复
学废啦imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E5%86%B7%E6%BC%A0.gif"alt="emotion_编程猫_冷漠"
2022-06-06T18:25:05 点赞:0
在 怎么用代码表示碰到冰块🧊破裂,等一会儿又复原 中回复
world.onPlayerJoin(({ entity }) => {
entity.onVoxelContact(async({ x, y, z, voxel}) => {
if (voxels.name(voxel) == 'ice'){
voxels.setVoxel(x, y, z, 0);
await sleep(3000);
voxels.setVoxel(x, y, z, 'ice');
};
});
});2022-06-11T19:08:58 点赞:0