
Lv.1
在 【up计划】首批优质地图出炉! 中回复
哇呜,玩具猴的五夜后宫的图片里面是我!imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%B4%A7%E5%BC%A0.gif"alt="emotion_编程猫_紧张"
2022-01-28T18:46:16 点赞:0
在 #新春创作节 《飞天任务》 帖子 中回复
这里是代码公布:
var jvbaoxiang=['举报箱内容如下:']
var jvbaoxiangshu=0;
const elevator = world.querySelector('#电梯-1') //获取电梯板实体
elevator.fixed = true//不受外力影响
elevator.collides = true//允许碰撞
const startPos = [81.31, 9.03, 9.36]//电梯的最低位置
const endPos = [81.31, 22.59, 9.36]//电梯的最高位置
const ani = elevator.animate([// 1+5+1+2=9, 总时间15秒被切成9份
{ position: startPos, duration: 1 },// 1/9 的时间停留在地面
{ position: startPos, duration: 5 },// 5/9 的时间用于地面往楼顶移动
{ position: endPos, duration: 1 },// 1/9 的时间停留在楼顶
{ position: endPos, duration: 2 },// 2/9 的时间从楼顶回到地面
], {
duration: 16 * 15, //播放一个循环共用时15秒,
iterations: 1,//动画只播放1次
direction: Box3AnimationDirection.WRAP,//让动画实体从终点回到起点
})
ani.onReady(() => {//当动画开始播放时
world.say('电梯准备启动')
})
ani.onFinish(() => {//当动画结束播放时
world.say('电梯自己停了')
})
world.onPress(({ button,entity }) => {
if(entity.diyiguo==true)
if (button === Box3ButtonType.ACTION0) {
//左键重新播放动画
ani.play({
duration: 16 * 15, //播放一个循环共用时15秒(每秒16帧),
iterations: 1,//动画无限次循环播放
direction: Box3AnimationDirection.WRAP,//让动画实体从终点回到起点
})
}
})
world.onPlayerJoin(({ entity })=> {
entity.diyiguo=false
entity.dierguo=false
})
var jiangbei=world.querySelector('#奖杯-1')
jiangbei.enableInteract = true
jiangbei.interactRadius = 1
jiangbei.onInteract(({ entity }) => {
entity.player.directMessage('恭喜您过关第一关')
world.say('恭喜'+entity.player.name+'过关第一关')
entity.diyiguo=true
})
var jiangbei2=world.querySelector('#罐子-1')
jiangbei2.enableInteract = true
jiangbei2.interactRadius = 1
jiangbei2.onInteract(({ entity }) => {
entity.player.canFly=true
entity.player.directMessage('恭喜您过关第三关,现在,飞出这里!')
world.say('恭喜'+entity.player.name+'过关!')
entity.dierguo=true
})
var jiangbei3=world.querySelector('#火箭一一长征五号-3')
jiangbei3.enableInteract = true
jiangbei3.interactRadius = 50
jiangbei3.onInteract(({ entity }) => {
if(entity.diyiguo==true&&entity.dierguo==true){world.say('恭喜'+entity.player.name+'成功发射火箭!');}
})
const TEXT_PlAYER=['天我','亨利佐Yahoo!','吉吉喵']
world.onPlayerJoin(({ entity })=>{
if( !TEXT_PlAYER.includes( entity.player.name))
{
}
})
world.onPress(async({ button, entity })=>{
if(button=='action0')
{
const result2 = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:"控制面板",
content:`尊敬的玩家`+entity.player.name+`请选择命令:`,
options:['切换第一人称','切换第三人称','我要举报']
});
if(!result2 || result2 === null){return;}
switch(result2.index)
{
case 0:
entity.player.cameraMode = Box3CameraMode.FPS;
break;
case 1:
entity.player.cameraMode = Box3CameraMode.FOLLOW;
break;
case 2:{
const result3 = await entity.player.dialog({
type: Box3DialogType.INPUT,
title: "举报系统",
titleTextColor: new Box3RGBAColor(1, 1, 1, 1),
titleBackgroundColor: new Box3RGBAColor(0, 0, 0, 0.98),
content: `${entity.player.name},`,
confirmText: '确定', // 确定按钮上面的文字。按下确定按钮后,提交回答。
placeholder: '举报内容。', // 输入框背景上的提示文字。
});
// 如果玩家点击了屏幕其他区域,取消了对话框。
if(!result3 || result3 === null){
entity.player.directMessage('你似乎无视了举报系统。');
return;
}
entity.player.directMessage(`你回答了: ${result3}` );
jvbaoxiangshu++
jvbaoxiang[jvbaoxiangshu]=result3
}
}
}
})
world.onPress(async ({ button, entity }) => {
if (button == 'action1') {
if (TEXT_PlAYER.includes(entity.player.name)) {
const result = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: "命令系统",
content: `尊敬的作者,请选择您的命令。`,
options: ['开启飞行模式', '关闭飞行模式', '开启跳跃增强', '关闭跳跃增强', '开启速度加成', '关闭速度加成', '开启幽灵模式', '关闭幽灵模式', "开启隐形", "关闭隐形", '隐藏名字', '显示名字', '查看举报箱'] // 将提供玩家选择的选项放入数组里。
});
// 如果玩家点击了屏幕其他区域,取消了对话框。
if (!result || result === null) {
return;
}
// 判断玩家选了什么选项。
switch (result.index) {
case 0:
entity.player.canFly = true;
break;
case 1:
entity.player.canFly = false;
break;
case 2:
entity.player.jumpPower = 2;
entity.player.doubleJumpPower = 2;
break;
case 3:
entity.player.jumpPower = 0.96;
entity.player.doubleJumpPower = 0.9;
break;
case 4:
entity.player.walkSpeed = 10;
entity.player.runSpeed = 20;
entity.player.flySpeed = 30;
break;
case 5:
entity.player.walkSpeed = 0.22;
entity.player.runSpeed = 0.4;
entity.player.flySpeed = 30;
break;
case 6:
entity.player.spectator = true;
break;
case 7:
entity.player.spectator = false
break;
case 8:
entity.player.invisible = true;
break;
case 9:
entity.player.invisible = false;
break;
case 10:
entity.player.showName = false;
break;
case 11:
entity.player.showName = true;
break;
case 12:
{
for(const i of jvbaoxiang)
{
var jvbaoxiang2=[]
jvbaoxiang2.push(i)
}
const result = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: "举报箱",
titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
content: `${entity.player.name},请查看举报箱。`,
options: jvbaoxiang2, // 将提供玩家选择的选项放入数组里。
});
// 如果玩家点击了屏幕其他区域,取消了对话框。
if(!result || result === null){
entity.player.directMessage('您退出了举报箱');
return;
}
// 判断玩家选了什么选项。
}
default:
}}}}
);
world.ambientSound.sample = 'audio/Da Fault (Inspired by FORTNITE) - 8 Bit Universe.mp3';
const mscale = 1 / 16
const Quat = new Box3Quaternion(0, 0, 0, 1)
function buddyFollow(entity, mesh, y) {
const buddy = world.createEntity({
mesh,
position: entity.position,
meshScale: [mscale, mscale, mscale],
gravity: false, //不受重力影响
fixed: false, //可推移
collides: true, //可碰撞
friction: 0, //无摩擦力
mass: 0.01, //非常轻
})
const tgPos = entity.position//僚机的目标位置
const budPos = buddy.position//僚机的当前位置
const facing = entity.player.facingDirection//玩家的朝向
const ratio = 0.3//追随的灵敏度, 最好设在0.5左右, 1.0表示立即移到玩家位置
const dist = 2 //与玩家保持的距离
const yOffset = y //y轴位移, 保持僚机在头顶或脚下
const ticker = world.onTick(() => {
//要让小精灵跟在玩家背后, 需要计算xz轴的位移: 玩家朝向的反方向
const xOffset = -facing.x * dist
const zOffset = -facing.z * dist
//当前位置与目标位置在xyz轴的差距
const xDiff = tgPos.x - budPos.x
const yDiff = tgPos.y - budPos.y
const zDiff = tgPos.z - budPos.z
//计算xyz方向上 当前位置向目标位置靠拢的速度
const 喵 = (xDiff + xOffset) * ratio
const vy = (yDiff + yOffset) * ratio
const vz = (zDiff + zOffset) * ratio
buddy.velocity.set(喵, vy, vz)//设置僚机速度
if (buddy.velocity.sqrMag() > 0.005) {//速度要足够大, 才触发转向, 防止抖动
buddy.meshOrientation = Quat.rotateY(Math.atan2(zDiff, xDiff)) //让小精灵一直面向玩家
}
})
return () => {
ticker.cancel() //关掉tick循环
buddy.destroy() //移除僚机实体
}
}
world.onPlayerJoin(({ entity }) => {
entity.setPet = buddyFollow(entity, 'mesh/皮卡丘.vb', -5) //给玩家增加宠物
})
world.onPlayerLeave(({ entity }) => {
//玩家离开地图时, 切记一定要关掉tick循环以及销毁小精灵实体, 否则随着人数增加, 服务器积累到一定程度就会崩溃
entity.setPet() //干掉宠物
})2022-01-31T17:40:46 点赞:0
在 一个不讲武德的地图: 中回复
https://kitten4.codemao.cn/?invite_code=ZdVRY6T6我在编程猫发起了一个协作项目,点击链接即可加入一起创作!
2022-02-13T19:20:36 点赞:0
在 【UP计划】第二期优质地图出炉! 中回复
抗议!!!!!!!!!!!!!!!!!!!!!!! 这图难道不行吗? 神奇代码岛(codemao.cn) 帖子都发了! 编程猫社区-#新春创作节《飞天任务》帖子-编程学习交流(codemao.cn)
2022-02-17T20:21:26 点赞:0
在 热腾腾、刚出炉的新皮肤来咯! 中回复
吉吉喵,你漏人了!还有一个地图呢!链接:神奇代码岛(codemao.cn)imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E4%BC%A4%E5%BF%83.gif"alt="emotion_编程猫_伤心"
2022-02-23T18:36:00 点赞:0
在 热腾腾、刚出炉的新皮肤来咯! 中回复
吉吉喵,在吗,回我一下
我们的图早就发布了,也过审了(lv.14了都)
帖子也发了,作品名称:《喵任务》
把我们给补上,谢谢(我很想要新皮肤)
2022-02-24T19:21:01 点赞:0
在 教程师计划第二期:阿吉在召唤! 中回复
吉吉,我没有QQ也没有微信,我就在这儿提交了哈! BoxId:henglizuodandan 创作链接:神奇代码岛:空白地图(codemao.cn)
2022-03-18T20:51:09 点赞:0
在 教程师计划第二期:阿吉在召唤! 中回复
吉吉,我没有QQ也没有微信,我就在这儿提交了哈!BoxId:henglizuodandan创作链接:box3.codemao.cn/e/17bc7c47f27f6c59a5a6
2022-03-19T19:18:24 点赞:0
在 教程师计划第二期:阿吉在召唤! 中回复
box3.codemao.cn/e/17bc7c47f27f6c59a5a6,吉吉喵,链接在此,请您审核 我的boxId:henglizuodandan 我在岛三的昵称:亨利佐Yahoo! 上岛时间:半年+
2022-03-22T20:46:01 点赞:0
在 教程师计划第三期:门前有两棵树,一棵是枣树,另一棵…… 中回复
吉吉喵,我没有微信和QQ,我就在这儿提交了哈! 参赛专题:代码 代码岛昵称:亨利佐Yahoo! (注意,是英文感叹号) BoxId:henglizuodandan 链接:box3.codemao.cn/e/0eeb3ff895ebdaa37b7e
2022-03-30T20:47:54 点赞:0