
Lv.1
签名:为高考做准备
在 【API 教程三连更】 吉吉喵化身电工师傅 中回复
imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E6%90%93%E5%A4%B4.gif"alt="emotion_编程猫_搓头"
2021-12-04T18:05:19 点赞:0
在 发射一个模型【简陋教程】 中回复
首先,你得放个要发射的模型() 再放个用于装饰,拿在手上的模型() console.clear() const Quat = new Box3Quaternion(0,0,0,1) world.onRelease(async ({entity, button, raycast:{direction}}) => { //每当有按钮被按下 if (button == Box3ButtonType.ACTION0) { const 喵 = world.createEntity({ mesh:'发射的模型', position:entity.position, meshScale:new Box3Vector3(0.1, 0.1, 0.1), collides:false }) 喵.gravity = false const 喵_orientation = Quat.rotateY(Math.atan2(direction.z, direction.x)).rotateY(-Math.PI / 2).rotateY(-Math.PI / 2) 喵.meshOrientation.copy(喵_orientation) for(i = 0; i <= 4; i++){ 喵.position.x += direction.x 喵.position.z += direction.z await sleep(200) } await sleep(1000) 喵.destroy() } }) world.onPlayerJoin(({ entity }) => { entity.player.addWearable({ bodyPart: Box3BodyPart.RIGHT_HAND, mesh: '拿的东西', orientation: new Box3Quaternion(0, 180, 60, -160).rotateY(Math.PI / 2.5), scale: new Box3Vector3(1, 1, 1), offset: new Box3Vector3(0, 0.2, 0.6), }) doge~2022-05-04T14:36:18 点赞:0
在 【干货】box3中的计时器 中回复
world.querySelectorAll(".终点").forEach((e)=>{ e.onEntityContact(({other})=>{, varnow=newDate().valueOf(); varname=other.player.name; other.player.time=(now-other.player.starttime)/1000; if(other.player.time<bestResult){ bestResult=other.player.time; world.say(`恭喜@${name}以${other.player.time}秒的成绩打破记录!`); }else{ world.say(`@${name}跑完一圈,用时${other.player.time}秒.`); } world.say(`${other.player.name}已获得飞行+幽灵能力,其他的玩家们,加油哦`) other.canFly=true; other.player.spectator=true }) }) world.onPlayerJoin(({entity})=>{ entity.player.starttime=newDate().valueOf(); })2022-05-08T12:54:22 点赞:0
在 哈哈哈哈哈哈哈哈哈哈!!!!!!!代码来撸!!! 中回复
哈哈,你格式被吞了
world.onPlayerJoin(({ entity }) => { entity.enableDamage = true; entity.showHealthBar = true;
}) world.onVoxelContact(({ entity, voxel, x, y, z }) => { if (voxel === voxels.id('lava02')) { entity.hurt(30) ; } }) // 玩家喵时,等待5秒后复活。 world.onDie(async({ entity }) => { // 等待事件需要用 async if (!entity.isPlayer) return; // 不处理非玩家的喵事件 await sleep(3000); entity.player.forceRespawn(); // 让玩家重生 });
world.say(`欢迎大家来到僵尸校园,因为有人制作僵尸病毒,让这个学校的人都伽马染成了丧失`) /* 玩家进入游戏时,弹出一个欢迎对话框 */ world.onPlayerJoin(({entity}) => { entity.player.dialog({ type: Box3DialogType.TEXT, title: "zuo'zhe", content: `你好,${entity.player.name},很高兴认识你。`, }); })
const TEST_PLAYER = ['熙熙说乐高', '爽快的小电鼠bMMb', '', ''] world.onPlayerJoin(({ entity }) => { if (!TEST_PLAYER.includes(entity.player.name)) return; entity.player.canFly = true; });
// 在玩家离开液体时把在玩家头上的穿戴配件删除 world.onFluidLeave(({ entity }) => { if (!entity.isPlayer) return; const headWears = entity.player.wearables(Box3BodyPart.HEAD); // 假设只有1个装备 `headWears[0]` entity.player.removeWearable(headWears[0]); });
world.onPlayerJoin(({ entity }) => { entity.player.onPress(async ({ button }) => { if (button == Box3ButtonType.ACTION1) { // 将摄像机看向地图中心 const lookTarget = new Box3Vector3(63, 8, 63);
// 将摄像机的位置置于地图大概中心处,并往上拉升到y轴150处,确保看到完整的地形 const lookEye = new Box3Vector3(63, 150, 63);
// lookUp用来调整相机角度,可以使画面上下左右颠倒。默认值是(0,1,0) // 由于视线是俯视,需要确保lookUp与相机视线方向不平行,需修改为(1,0,0)或者(0,0,1) const lookUp = new Box3Vector3(1, 0, 0)
entity.player.dialog({ type: Box3DialogType.TEXT, content: `俯视`, lookEye: lookEye, lookTarget: lookTarget, lookUp: lookUp }) } }) }) console.clear() var door = world.querySelector('#-1') //名称需与模型的名称保持一致 door.enableInteract = true; door.interactRadius = 5; door.interactHint = '移到商店'
door.onInteract(({ entity }) => { entity.position.set(177,45,220) }) world.addCollisionFilter('player','player');
for (const e of world.querySelectorAll('*')) { //遍历每个实体 e.enableDamage = true //允许这个实体 受伤/喵/复活 e.collides = true //允许实体被碰撞 } // 碰到僵尸受伤, 碰到急救包恢复生命 world.onEntityContact(({ entity, other }) => { //other是被触碰的实体 if (other.hasTag('僵尸')) { //当被碰实体有僵尸标签 entity.hurt(20) //受伤 } })
world.onPlayerJoin(({entity}) => { entity.player.addWearable({ bodyPart: Box3BodyPart.HEAD, mesh: '鱿鱼游戏,角形面具.vb', //使用代码时,此处的名称需与地图中的模型名称保持一致 orientation: new Box3Quaternion(0,1,0,0).rotateY(-Math.PI/2), offset: new Box3Vector3(0,0.4,0.1), }); });
console.clear()
const mscale = 1 / 16 const n = [-4, -3, -2, -1, 0, 1, 2, 3, 4]
// 生成一堆小人 for (let x of n) { for (let y of n) { for (let z of n) { const e = world.createEntity({ mesh: '000.vb', //地图中需有一个名称为“小人”的模型 fixed: true, collides: false, position: [x * 4 + 喵, y * 3 + 16, z * 4 + 喵], meshScale: [mscale, mscale, mscale], }) e.enableDamage = true e.onDie(() => { e.destroy() }) } } }
world.onPlayerJoin(({ entity }) => { entity.enableDamage = true })
function killZone(pos, radius, fn) { //球状AOE for (const e of world.querySelectorAll('*')) {//遍历所有实体 const dist = e.position.distance(pos)//计算作用点与当前实体的距离 if (dist <= radius) {//当距离小于等于有效作用半径 fn(e, dist)//传递当前实体和距离到回调函数并执行 } } }
async function killBox(pos, size, fn) { //盒状AOE //搜索包围盒内的所有实体 const entities = world.searchBox({ lo: [pos.x - size, pos.y - size, pos.z - size], //包围盒下边界 hi: [pos.x + size, pos.y + size, pos.z + size], //包围盒上边界 })
for (const e of entities) { //遍历所有找到的实体 fn(e) } }
async function makeDamage(e, dmg, color) { e.hurt(Math.max(1, dmg)) //max用于防止负数伤害
e.meshColor.copy(color) //当前实体变色 await sleep(500) e.meshColor.set(1, 1, 1, 1) //恢复正常颜色 }
const RED = new Box3RGBAColor(1, 0, 0, 1) const GREEN = new Box3RGBAColor(0, 1, 0, 1) const BLUE = new Box3RGBAColor(0, 0, 1, 1) world.onPress(({ entity, button, raycast }) => { if (button === Box3ButtonType.CROUCH) { //下蹲键触发自身球状AOE const range = 8//AOE有效作用半径 killZone(entity.position, range, async (e, dist) => { if (e === entity) return//如果当前实体是AOE施放者, 就不继续执行, 避免伤到自己 const ratio = (range - dist) / range //计算距离百分比, 离得越近ratio越趋向1, 离得越远ratio越趋向0 makeDamage(e, 20 * ratio, RED) }) } else if (button === Box3ButtonType.ACTION0) { //左键触发远距离球状AOE const range = 8//AOE有效作用半径 killZone(raycast.hitPosition, range, async (e, dist) => { if (e === entity) return//如果当前实体是AOE施放者, 就不继续执行, 避免伤到自己 const ratio = (range - dist) / range //计算距离百分比, 离得越近ratio越趋向1, 离得越远ratio越趋向0 makeDamage(e, 20 * ratio, GREEN) }) } else if (button === Box3ButtonType.ACTION1) { //右键触发远距离盒状AOE const size = 7 //AOE盒的大小 killBox(raycast.hitPosition, size, (e) => { if (e === entity) return//如果当前实体是AOE施放者, 就不继续执行, 避免伤到自己 makeDamage(e, 20, BLUE) }) } })
console.clear() var door = world.querySelector('#4') //名称需与模型的名称保持一致 door.enableInteract = true; door.interactRadius = 5; door.interactHint = '移到酒店'
door.onInteract(({ entity }) => { entity.position.set(209,20,241) }) world.addCollisionFilter('player','player');2022-05-09T10:45:31 点赞:0
在 【JS解密】这是一段被多重加密的文字,你能破解吗? 中回复
请解密:U2FsdGVkX19dzhSuS9Czmrjr0hP+9N2m//qOeyupqGuF17ZlmirXOHOKNg==
2022-06-01T21:18:15 点赞:0