Lv.1
你好……人类
签名:改进游戏,创作一个教学
在 【神岛场景创作小技巧】猜猜这些动效是如何实现的? 中回复
//旋转动画
async function loopRotateEntityZ(entityName, time = 30, angle = -Math.PI / 36) { //loopRotateEntity=90度类型
const entity = world.querySelector(`#${entityName}`)
while (1) {
await sleep(time)//数越小越快
entity.meshOrientation = entity.meshOrientation.rotateZ(angle)//PI=180度
}
}
async function loopRotateEntityX(entityName, time = 30, angle = -Math.PI / 36) { //loopRotateEntity=90度类型
const entity = world.querySelector(`#${entityName}`)
while (1) {
await sleep(time)//数越小越快
entity.meshOrientation = entity.meshOrientation.rotateX(angle)//PI=180度
}
}
world.querySelectorAll('*').forEach(e => {
if (e.id.startsWith('水车')) {
loopRotateEntityX(e.id, 30, Math.PI / 36)
}
})
world.querySelectorAll('*').forEach(e => {
if (e.id.startsWith('水动X')) {
loopRotateEntityX(e.id, 100, Math.PI / 1)
}
})
world.querySelectorAll('*').forEach(e => {
if (e.id.startsWith('水动Z')) {
loopRotateEntityZ(e.id, 100, Math.PI / 1)
}
})
loopRotateEntityZ('风车部件01-1')
loopRotateEntityZ('风格部件03-1')2022-07-07T19:48:21 点赞:0
在 【每日一个岛3建图小技巧】拥有一个跟随的皮卡丘?就决定是你啦! 中回复
console.clear()
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', -1) //给玩家增加宠物
})
world.onPlayerLeave(({ entity }) => {
//玩家离开地图时, 切记一定要关掉tick循环以及销毁小精灵实体, 否则随着人数增加, 服务器积累到一定程度就会崩溃
entity.setPet() //干掉宠物
})
2022-08-13T18:33:51 点赞:0
在 【每日一个岛3建图小技巧】拥有一个跟随的皮卡丘?就决定是你啦! 中回复
代码在这,不用谢我。
console.clear()
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', -1) //给玩家增加宠物
})
world.onPlayerLeave(({ entity }) => {
//玩家离开地图时, 切记一定要关掉tick循环以及销毁小精灵实体, 否则随着人数增加, 服务器积累到一定程度就会崩溃
entity.setPet() //干掉宠物
})
)m2022-08-13T18:35:12 点赞:0
在 【像素类沙盒作品教程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-09-05T20:53:26 点赞:0
在 圆周率小数点第1000000位 中回复
3.14159 26535 89793 23846 2喵33
83279 50288 41971 69399 37510
58209 74944 59230 781喵 06286
20899 86280 34825 34211 70679
82148 08651 32823 06喵7 09384
46095 50582 23172 53594 08128
48111 74502 84102 70193 85211
05559 喵462 29489 54930 38196
44288 10975 66593 34461 28475
喵823 37867 83165 27120 19091
45喵8 56692 34603 48610 45432
6喵82 13393 60726 02491 41273
72458 70066 06315 58817 48815
20920 96282 92540 91715 3喵36
78925 90360 01133 05305 48820
46652 13841 46951 94151 16094
33057 27036 57595 91953 09218
61173 81932 61179 31051 18548
07446 23799 62749 56735 18857
52724 89122 79381 83011 94912
圆周率501-1000位
98336 73362 44065 6喵30 86021
39494 63952 24737 19070 21798
60943 70277 05392 17176 29317
67523 84674 81846 76694 05132
00056 81271 45263 56082 77857
71342 75778 96091 73637 17872
14684 40901 22495 34301 46549
58537 10507 92279 68925 89235
42019 95611 21290 21960 8喵03
44181 59813 62977 47713 09960
51870 72113 49999 99837 29780
49951 05973 17328 16096 31859
50244 59455 34690 83026 42522
30825 33446 85035 26193 11881
71010 00313 78387 52886 58753
32083 81420 61717 76691 47303
59825 34904 28755 46873 11595
62863 88235 37875 93751 95778
18577 80532 17122 68066 13001
92787 66111 95909 21喵2 01989
圆周率1001-1500位
38095 25720 10654 85863 27886
59361 53381 82796 82303 01952
03530 18529 68995 77362 25994
13891 24972 17752 83479 13151
55748 57242 45415 06959 50829
53311 68617 27855 88907 50983
81754 63746 49393 19255 06040
09277 01671 13900 98488 24012
85836 16035 63707 66010 47101
81942 95559 61989 46767 83744
94482 55379 77472 68471 04047
534喵 62080 46684 25906 94912
93313 67702 89891 52104 75216
20569 66024 05803 81501 93511
25338 24300 35587 喵024 749喵
73263 91419 92726 04269 92279
67823 54781 63600 93417 21喵1
21992 45863 15030 28618 29745
55706 74983 85054 94588 58692
69956 90927 21079 75093 02955
圆周率1501-2000位
32116 53449 87202 75596 023喵
80665 49911 98818 34797 75356
63698 07426 54252 78625 51818
41757 46728 90977 77279 38000
81喵7 06001 61452 49192 17321
72147 72350 14144 19735 68548
16136 11573 52552 13347 57418
49468 43852 33239 07394 14333
45477 62416 86251 89835 69485
56209 92192 22184 27255 02542
56887 67179 04946 01653 46680
49886 27232 79178 60857 84383
82796 79766 81454 10095 38837
86360 95068 00喵2 25125 20511
73929 84896 08412 84886 26945
60424 19652 85022 21066 11863
06744 27862 20391 94945 04712
37137 86960 95636 43719 17287
46776 46575 73962 41389 08658
32喵5 99581 33904 78027 59009
2022-09-16T21:45:14 点赞:0
在 【神岛创作节】圣诞创作节比赛结束时间延长至19日晚24点~ 中回复
【皮肤申请】
-链接:https://box3.codemao.cn/g/50034452
作者:刺客组织万嘉麒 代码 https://box3.codemao.cn/u/tZwRPSMpTt2ntqB
合作者:
天魔小熊熊 测试 10%建筑https://box3.codemao.cn/u/code023442y
迷糊de糖糖 75%建筑 https://box3.codemao.cn/u/code95240d7
玩命喵 15%建筑https://box3.codemao.cn/u/KFJMRZRkKAWnup3
Enjoy纸方工作室(出海喵) 写bug+凑数https://box3.codemao.cn/u/7Y5HjDkrEyWLu7F
玩法如下:
比赛准备:请在出生点旁的告示牌参加游戏
第一关:当开始游戏时你将会是一个礼盒或人类,当你是礼盒时,需要小心人类抓到(碰到)你,你可以对人类进行瞄准攻击,当你是一个人类时,你需要碰到礼盒而击败
第二关:你需要快速开车到达终点,限时30秒,前五名即可晋级,时间结束后未到达终点的选手会被淘汰
第三关:你需要用尽快到达终点取得胜利,如果掉下去不会复生
地图优点:
多人对决,角色随机
代码完整无bug
地图运行流畅
求皮肤
2022-12-20T15:07:22 点赞:0
在 【求助】求说一句话就能让玩家复活的代码 中回复
world.onPlayerJoin(({entity})=>{ entity.enableDamage=true }); world.onChat(({entity,message})=>{ switch(message){ case'die': if(entity.player.dead){//如果在说话时已经喵则跳过 entity.player.directMessage('你目前已经倒地了。'); return; } entity.hurt(entity.maxHp) break; case'revive': if(!entity.player.dead){//在说话时,是否已经喵 entity.player.directMessage('你目前还很健康'); return; } entity.hp=entity.maxHp entity.player.directMessage('原地满血复活!'); break; default: break; } })2022-12-29T20:21:08 点赞:0