猫史档案馆


Bocchii

Bocchii

Lv.1

ぼっち... 这里全部是黑历史…不要再看了谢谢ww

获赞:148收藏:86浏览:1206作品收藏:44

签名:寻找删除黑历史的方法… …怎么没有 ↑突然在一个论坛里看到了codemao然后来看的笨 蛋一枚

回复帖子评论
上一页1 页 / 共 2下一页

【我在室长的购买机器人卡出bug了!】选择框位移了! 中回复

emotion_编程猫_加油

2020-03-20T16:52:52 点赞:0

【我在室长的购买机器人卡出bug了!】选择框位移了! 中回复

emotion_编程猫_点赞

2020-03-20T16:53:35 点赞:0

素材找不到 中回复

emotion_编程猫_点赞

2020-03-28T09:54:10 点赞:0

素材找不到 中回复

emotion_雷电猴_摇椅子

https://static.codemao.cn/emotion/thunder_monkey/%E6%91%87%E6%A4%85%E5%AD%90240.gif

2020-03-28T09:56:06 点赞:0

素材找不到 中回复

https://static.cod喵/emotion/thunder_monkey/%E6%91%87%E6%A4%85%E5%AD%90240.gifhttps://static.cod喵/emotion/thunder_monkey/%E6%91%87%E6%A4%85%E5%AD%90240.gifhttps://static.cod喵/emotion/thunder_monkey/%E6%91%87%E6%A4%85%E5%AD%90240.gif

2020-03-28T09:59:34 点赞:0

素材找不到 中回复

 

emotion_雷电猴_举手

2020-03-28T10:00:00 点赞:0

素材找不到 中回复

emotion_星能猫_爱你

2020-03-28T10:00:15 点赞:0

有知道通天塔的源码币有什么用的吗<[>--<]> 中回复

购买作品

2020-03-28T10:26:01 点赞:0

🧬【源代码全公开!】圈地之王开发接力挑战 中回复

const SECONDS_PER_TICK = 1000 / 128; 
const ROUND_TIME = 200 * SECONDS_PER_TICK;//每局游戏时长
const MIN_PLAYERS = 2;//玩家数量下限
const GRID_X = 128;
const GRID_Z = 128;

const TEAMS = [
    { r: 1, g: 0, b: 0, v: voxels.id('red_light'),      n: '红队',       score: 0, },
    { r: 0, g: 1, b: 0, v: voxels.id('green_light'),    n: '绿队',     score: 0, },
    { r: 0, g: 0, b: 1, v: voxels.id('blue_light'),     n: '蓝队',      score: 0, },
    { r: 1, g: 0, b: 1, v: voxels.id('purple'),         n: '紫队',   score: 0, },
    { r: 0, g: 1, b: 1, v: voxels.id('indigo_light'),   n: '靛蓝队',      score: 0, },
    { r: 1, g: 1, b: 0, v: voxels.id('yellow_light'),   n: '黄队',    score: 0, },
];

// 辅助函数,用于随机打乱一个数组
function shuffle (array) {
    for (let i = 1; i < array.length; ++i) {
        const temp = array[i];
        const x = (Math.random() * (i + 1)) | 0;
        array[i] = array[x];
        array[x] = temp;
    }
    return array;
}

async function startGame () {
    // 将地面初始化,全部变成不锈钢
    for (let j = 0; j < GRID_Z; ++j) {
        for (let i = 0; i < GRID_X; ++i) {
            voxels.setVoxel(i, 8, j, 'stainless_steel');
        }
    }
    
    // 等待玩家进入
    while (world.querySelectorAll('player').length < MIN_PLAYERS) {
        world.say('等待其他玩家加入...');
        await sleep(1000);
        world.say('2个玩家立即开始');
        await world.nextPlayerJoin();
    }

    // 足够玩家加入后,就开始倒计时
    for (let i = 3; i > 0; --i) {
        world.say(i + '...');
        await sleep(1000);
    }
    world.say('去圈地吧!看谁是圈地之王?');
    
    // 每局都随机打乱队伍
    const players = shuffle(world.querySelectorAll('player'));
    shuffle(TEAMS);
    
    // 设置玩家的颜色和初始位置
    function setTeam (p, t) {
        p.player.color.r = t.r;
        p.player.color.g = t.g;
        p.player.color.b = t.b;
        p.position.x = Math.random() * GRID_X;
        p.position.y = 30;
        p.position.z = Math.random() * GRID_Z;
    }

    // 获得初始团队
    const teams = players.map((p, i) => {
        const t = TEAMS[i % TEAMS.length]
        setTeam(p, t);
        return t;
    })
    
    //当玩家接触到地面任意方块时,更新该方块的颜色
    const contactHandler = world.onVoxelContact(({ entity, x, y, z }) => {
        const idx = players.indexOf(entity);
        if (idx < 0) {
            return;
        }
        const t = teams[idx];
        voxels.setVoxelId(x, y, z, t.v);
    });
    
    // 新玩家加入,会被随机分配到一个队伍
    const joinHandler = world.onPlayerJoin(({entity}) => {
        const t = TEAMS[(Math.random() * teams.length) | 0];
        setTeam(entity, t);
        teams.push(t);
        players.push(entity)
    });
    
    // 每局游戏会在计时到达时结束。
    const endTick = world.currentTick + ROUND_TIME;
    
    // 检测游戏是否进行中
    function gameInProgress () {
        let numActivePlayers = 0;
        for (let i = 0; i < players.length; ++i) {
            if (!players[i].destroyed) {
                numActivePlayers += 1;
            }
        }
        return world.currentTick < endTick && numActivePlayers >= MIN_PLAYERS;
    }
    
    // 通过深度优先搜索,将圈起来的地自动填色
    const visited = new Uint8Array(GRID_X * GRID_Z)
    const toVisit = []
    function mark (i, j, team) {
        const idx = i + j * GRID_X;
        if (i < 0 || i >= GRID_X ||
            j < 0 || j >= GRID_Z ||
            visited[idx] ||
            voxels.getVoxel(i, 8, j) === team) {
            return;
        }
        visited[idx] = true;
        toVisit.push(i, j);
    }
    function fillHoles (team) {
        visited.fill(0);
        for (let i = 0; i < Math.max(GRID_X, GRID_Z); ++i) {
            mark(i, 0, team);//更正了,将8改成了0
            mark(0, i, team);
            mark(GRID_X - 1, i, team);
            mark(i, GRID_Z - 1, team);
        }
        
        while (toVisit.length > 0) {
            const z = toVisit.pop() | 0;
            const x = toVisit.pop() | 0;
            mark(x - 1, z, team);
            mark(x + 1, z, team);
            mark(x, z - 1, team);
            mark(x, z + 1, team);
        }
        
        let score = 0;
        for (let j = 0; j < GRID_Z; ++j) {
            for (let i = 0; i < GRID_X; ++i) {
                const idx = i + j * GRID_X;
                if (!visited[idx]) {
                    voxels.setVoxelId(i, 8, j, team);
                    score += 1;
                }
            }
        }
        return score;
    }
    
    // 当游戏运行时
    while (gameInProgress()) {
        // 等待 1 Tick
        await world.nextTick();
        
        // 计算各队伍的分数
        for (let i = 0; i < TEAMS.length; ++i) {
            const c = TEAMS[i].score = fillHoles(TEAMS[i].v);
            
            // 如果有团队圈完全场,那么直接胜出
            if (c >= GRID_X * GRID_Z) {
                break;
            }
        }
    }
    
    // 清除事件处理器
    contactHandler.cancel();
    joinHandler.cancel();

    // 重置玩家颜色
    for (let i = 0; i < players.length; ++i) {
        const c = players[i].player.color;
        c.r = c.g = c.b = 1;
    }
    world.say('本局游戏结束!');
    await sleep(5000);
    
    // 宣布获胜队伍
    TEAMS.sort((a, b) => b.score - a.score);
    world.say(`恭喜 ${TEAMS[0].n} 成为圈地之王!!`);
    await sleep(10000);
}

// 无限循环游戏
async function gameLoop () {
    while (true) {
        await startGame();    
    }
}
gameLoop();

2020-04-12T11:18:24 点赞:0

(获奖名单见评论区置顶)【六一活动】来时光游乐园玩游戏、寻线索、找宝藏! 中回复

【确定密码】61时光重返童年

2020-05-30T10:12:38 点赞:0

找徒弟啦啦啦啦! 中回复

我要当徒弟

2020-06-22T07:29:31 点赞:0

【找徒弟】(水) 中回复

我想当徒弟

2020-06-22T07:30:57 点赞:0

【找徒弟】(水) 中回复

行不

 

2020-06-22T07:31:04 点赞:0

【收徒】GHS的冥 中回复

我要当emotion_编程猫_加油我正好有一个问题想请教你

2020-06-22T07:32:15 点赞:0

我有岛三编辑权啦! 中回复

我也想要emotion_编程猫_点赞

2020-08-29T09:22:37 点赞:0

想要编辑权的人请进 中回复

应聘+代码师低级

2020-08-29T09:24:06 点赞:0

新地图游乐园招人啦! 中回复

建筑师!

2020-08-29T09:28:02 点赞:0

我有岛三编辑权啦! 中回复

我太需要了

2020-08-29T09:30:07 点赞:0

新地图游乐园招人啦! 中回复

有人搞破坏!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

2020-08-29T11:07:27 点赞:0

新地图游乐园招人啦! 中回复

一级战备状态!Kn光影猫的地图有人搞破坏!!!!!!

 

2020-08-29T11:08:39 点赞:0

新地图游乐园招人啦! 中回复

紧急求教!所有代码被删了!!!我设置的出生点也被删了!

2020-08-29T11:10:52 点赞:0

新地图游乐园招人啦! 中回复

紧急求救!地图被破坏了!

2020-08-29T11:14:12 点赞:0

OMG!!!! 中回复

也给我一张!emotion_编程猫_谢谢老板

2020-08-29T14:17:19 点赞:1

跑酷第一期地图招人啦! 中回复

网址:https://box3create.cod喵/games/116562ef05e901c40bff

进去就点击:申请编辑

2020-08-29T14:18:38 点赞:0

送代码岛3地图了 中回复

我来!

2020-08-29T14:27:24 点赞:0

送代码岛3地图了 中回复

给我1张

 

2020-08-29T14:27:31 点赞:0

跑酷第一期地图招人啦! 中回复

dd有人吗?

2020-08-29T14:28:07 点赞:0

送代码岛3地图了 中回复

在吗?dd在吗?dd在吗???

2020-08-29T14:29:59 点赞:0

大型赛车地图招人了! 中回复

我来啦!

2020-08-30T07:57:31 点赞:0

快来领代码呀! 中回复

百度链接:https://pan.喵/s/1YGQMHxi7ve4tb1OMAcUgUQ
提取码:4qul

2020-12-19T13:09:09 点赞:0