用户:
烨烨小栗子查看:0 回复:4 评论:0 创建时间:2022-07-15T16:26:45
????????????????????、
function sphere(vox, cx, cy, cz, radius){
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.onPlayerJoin(({entity})=>{
entity.id = entity.player.name
})
world.querySelectorAll('*').forEach((e)=>{
if(e.id != '[星球大战]TIE截击战机-1')e.collides = true
})
// sphere('air',63,24,63,12) // 调用方法。在{x:63, y:24, z:63} 位置,建造一个半径为12格的实心球体
const thePoint = world.querySelector('#[星球大战]TIE截击战机-1'); // 搜索模型名字为"出生点-1"的首个实体
(async function(){
while(1){
const a = world.createEntity({
mesh:'mesh/追踪导弹.vb',
position:thePoint.position,
meshScale:[1/6,1/6,1/6],
fixed:false,
collides:true,
gravity:true,
})
a.velocity = new Box3Vector3(Math.random()*10,0,Math.random()*10)
a.onEntityContact(async({other})=>{
if(other.id == '[星球大战]TIE截击战机-1') return
other.enableDamage = true
other.hp -= 100
if(other.hp <= 0){
a.destroy()
sphere('air',other.position.x,other.position.y,other.position.z,10)
other.hp = 0
await sleep(4000)
other.hp = 100
world.say(other.id+'复活了')
}
})
a.onVoxelContact(({
x,y,z
})=>{
a.destroy()
sphere('air',x,y,z,10)
})
thePoint.say('破坏家园!哈哈哈哈')
await sleep(4000)
}
}
)();
//配置模型:1.一个名为[星球大战]TIE截击战机-1
//文件:一个叫追踪导弹的模型
点赞0
评论