
Lv.1
一个普通的编程小白
签名:阿巴阿巴阿巴 这年头谁在社区混() 快来你岛
在 【教程】模板太单一?教你自己生成山水图! 中回复
没有注释版本,放控制台粘这个
for (let i = 0; i < 127; i++) {
for (let j = 0; j < 127; j++) {
voxels.setVoxel(i, 8, j, 'water');
}
}
function mountain() {
var x = Math.floor(Math.random() * 127);
var z = Math.floor(Math.random() * 127);
var vis = [];
for (let i = 0; i < 127; i++) {
var k = [];
for (let j = 0; j < 127; j++) {
k.push(false);
}
vis.push(k);
}
dfs(x, z, Math.floor(Math.random() * 10 + 45), vis);
}
function column(x, z, heigth) {
for (let y = 8; y <= heigth + 6; y++) {
voxels.setVoxel(x, y, z, 'dirt');
}
voxels.setVoxel(x, heigth + 7, z, 'grass');
}
function dfs(x, z, heigth, vis) {
if (x < 0 || x >= 127 || z < 0 || z >= 127) return;
if (heigth <= 0) return;
if (vis[x][z]) return;
vis[x][z] = true;
column(x, z, heigth);
if (Math.random() > 0.4)
dfs(x + 1, z, heigth + Math.floor(Math.random() * 10 - 6), vis);
if (Math.random() > 0.4)
dfs(x - 1, z, heigth + Math.floor(Math.random() * 10 - 6), vis);
if (Math.random() > 0.4)
dfs(x, z - 1, heigth + Math.floor(Math.random() * 10 - 6), vis);
if (Math.random() > 0.4)
dfs(x, z + 1, heigth + Math.floor(Math.random() * 10 - 6), vis);
}
mountain();
mountain();
mountain();
mountain();
mountain();
mountain();
mountain();2022-04-08T17:06:54 点赞:1
在 【教程】教你做一个假控制台 中回复
大家凑合看吧,以下是完整代码
class Box3FakeConsole{
constructor(consoleName,initial){
this.name=consoleName;
this.text=String(initial);
}
log(...args){
for(const t of args){
this.text+=String(t)+' ';
}
this.text+='\n';
}
error(...args){
this.text+='<error\n'
for(const t of args){
this.text+=String(t)+' ';
}
this.text+='\nerror>\n'
}
clear(){
this.text='';
}
async show(entity){
if(!entity.isPlayer)return;
while(true){
const p=await entity.player.dialog({
type:Box3DialogType.INPUT,
title:this.name,
content:this.text,
})
if(!p||p==null)break;
this.log('~> '+p);
try{
this.log('<~ '+eval(p));
}catch(e){
this.error('<~ '+e);
}
}
}
}2022-04-28T19:47:27 点赞:0
在 【神岛】那些代码很牛的大佬,见到这个人,看都别看一眼,赶紧跑! 中回复
不至于吧,现在我和做的图里面有大部分不知道我会代码,装就完了。首先,你需要有很好的建筑技能;其次,无论他的代码犯了多么蠢的错误都要忍住不要冲动去改;第三,不要说你不会代码,而是故意写出一些错(类似于const a=1;a++;这种),让他彻底放弃你的代码。
2022-05-16T15:01:19 点赞:0
在 求可以让玩家在弹窗自行选择BGM的代码 中回复
music
• music: Box3SoundEffect‹› = new Box3SoundEffect()
为指定的玩家播放背景音乐(循环播放),此声音仅该玩家能听见,其他玩家无法听到。 背景音乐的音量会根据用户在[设置-声音]更改。
// 将玩家背景音乐设置为电声
entity.player.music.sample = 'audio/electic.mp3';
entity.player.music.gain = 0.5; // 音量 50%2022-05-19T16:21:32 点赞:1