用户:
async_function查看:0 回复:7 评论:0 创建时间:2021-04-03T18:24:18
烟花代码(超大地图)
async function Fire() {//烟花(爆炸型)
const random1 = Math.random(), random2 = Math.random(), random3 = Math.random(), random4 = Math.random()
const fire = world.createEntity({
gravity: false,
collides: false,
position: new Box3Vector3(Math.random() * 128, 128, Math.random() * 128),
particleSize: [8, 6, 4, 2],
particleRate: 1,
particleLifetime: 0.07,
particleVelocity: new Box3Vector3(0, 0, 0),
particleVelocitySpread: new Box3Vector3(45, 45, 45),
particleDamping: -1,
particleRateSpread: 500,
particleColor: new Box3RGBColor(random1 * 40, random2 * 2, random3 * 2)
})
fire.particleRate = 0
for (let x = 0; x < 128; x++) {
await sleep(20)
fire.position.y++
}
await sleep(2560)
fire.addTag('fire')
fire.particleRate = 1200
fire.particleLifetime = 1
if (random4 < 0.33) {
fire.particleColor = new Box3RGBColor(random1 * 40, random2 * 2, random3 * 2)//red
} else if (random4 < 0.66) {
fire.particleColor = new Box3RGBColor(random1 * 2, random2 * 30, random3 * 2)//green
} else {
fire.particleColor = new Box3RGBColor(random1 * 2, random2 * 2, random3 * 40)//blue
}
await sleep(5000)
world.querySelectorAll('.fire').forEach((e) => { if (!e.isPlayer) { e.destroy() } })
}
Fire()