猫史档案馆


可靠的蓝甲虫sDuG

可靠的蓝甲虫sDuG

Lv.1

获赞:9收藏:3浏览:50作品收藏:0
回复帖子评论
上一页2 页 / 共 2下一页

求合作(代码岛3.0) 中回复

https://box3create.codemao.cn/games/8b6e09931437eb953edb

2020-11-08T13:00:58 点赞:0

【1.用H喵L,CSS,JavaScript代码做网页教程1】 中回复

喵=喵

2020-11-14T10:06:31 点赞:0

【1.用H喵L,CSS,JavaScript代码做网页教程1】 中回复

ml

2020-11-14T10:06:52 点赞:0

我想跟人合作 中回复

我!11

2020-11-14T10:08:29 点赞:1

管喵代码全揭秘(其他板) 中回复

报错!

2020-11-14T10:24:50 点赞:0

多层喵战招人了!!! 中回复

wo

 

2020-11-15T08:36:46 点赞:0

地图速建教程【开心的小电鼠】 中回复

emotion_编程猫_点赞

2020-11-15T09:30:51 点赞:0

【岛3-API教程3!】用方块检测,做一片刀山火海🌋 中回复

function cylinder(cx,cy,cz,vox,radius,height){
  var xend = cx+radius
  var yend = cy+height
  var zend = cz+radius
  for(var x=cx-radius;x<=xend;x++){
    for(var z=cz-radius;z<=zend;z++){
      var dx = x-cx;
      var dz = z-cz;
      if(Math.round(Math.sqrt(dx*dx+dz*dz))<=radius){
        for(var y=cy;y<yend;y++){
          voxels.setVoxel(x,y,z,vox)
        }
      }
    }
  }
}

for(var i=0;i<300;i++){ // 300个随机圆柱体构成场景
  let x = Math.random() * 125 // x坐标
  let z = Math.random() * 125 // z坐标
  let h = Math.random() * 4 // 高 0~4
  let r = 2 + Math.random() * 5 //半径 2~7
  cylinder(x,9+Math.random()*40,z,'dirt',r,h)
}

for(var y=9;y<52;y++){//扫描9~52层的格子
  for(var x=0;x<127;x++){
    for(var z=0;z<127;z++){
      // 如果当前格子不为空而它上面那格是空的, 则表示它是复杂地形的表面 
      if(voxels.getVoxel(x,y,z)!=0 && voxels.getVoxel(x,y+1,z)==0){
        voxels.setVoxel(x,y,z,'grass')// 土块替换成喵地
        
        // 在喵地上以3%的几率生成3种植物的其中一种
        var rnd = Math.random()
        var cx = x+0.5 // 修正到方块中心的x坐标
        var cz = z+0.5 // 修正到方块中心的z坐标
        if(rnd<0.01){
          spawn(cx,y+1,cz,'mesh/树.vb',3+2.5*Math.random())
        }else if(rnd<0.02){
          spawn(cx,y+1,cz,'mesh/花.vb',0.8)
        }else if(rnd<0.03){
          spawn(cx,y+1,cz,'mesh/茂盛的喵.vb',0.8)
        }
      }
    }
  }
}

async function correctY(entity){
  await sleep(1)//entity.bounds需要等到下一个tick才会变成真正的值
  entity.position.y += entity.bounds.y//bounds.y是中心点到模型顶部或底部的距离
}

function spawn(x,y,z,meshName,scale){
  const meshScale = scale/16 //默认模型方块大小倍数为地图方块的1/16
  const entity = world.createEntity({
    mesh:meshName,//模型名
    collides:false,//不能碰撞
    fixed:true,//固定
    gravity:false,// 不受重力影响
    meshScale:[meshScale,meshScale,meshScale],//xyz放大倍数
    position:[x,y,z],//位置坐标
  })
  correctY(entity)
  return entity
}

2020-11-21T10:55:36 点赞:0

【API 教程三连更】 吉吉喵化身电工师傅 中回复

nb

2020-12-01T17:25:11 点赞:0

【Box3特辑】源灵高速路发展史 中回复

emotion_编程猫_点赞

2020-12-06T14:11:40 点赞:0

【模型好多】 中回复

地图

 

2020-12-20T12:25:03 点赞:1

重大坏消息!!!!!!!!!!!!!!!!!!!!!!! 中回复

......

 

2021-01-01T07:29:39 点赞:0

[干货] 如何用粒子特效实现"掉"血特效 中回复

emmmmmmmmmmm...........

2021-01-29T12:12:55 点赞:0

【代码岛3.0内测第13弹!】官网更新!粒子特效! 中回复

哇!!!

2021-01-29T12:15:21 点赞:0

【岛3大更新】猜猜这次有什么大惊喜? 中回复

https://box3.codemao.cn/u/UTRE

2021-01-30T19:33:12 点赞:0

【岛3大更新】猜猜这次有什么大惊喜? 中回复

我画的最好的模型:https://box3.codemao.cn/v/729喵

2021-01-30T19:34:28 点赞:0

https://box3.codemao.cn/e/1742c6da53a9a7a28f99 中回复

存档代码:

for (const e of world.querySelectorAll('*')) {
    if (e.id.startsWith('存档点')) {
        e.meshScale = e.meshScale.scale(1)
        e.onEntityContact(({ other }) => { 
            if (other.isPlayer) { 
                if (e.position !== other.player.spawnPoint) { 
                    other.player.directMessage('存档成功!')
                    other.player.spawnPoint = e.position
                }
            }
        })
    }
}

2023-06-29T20:37:50 点赞:0