猫史档案馆


array_已退

array_已退

Lv.1

逊哥array,啥也不会 退了退了

获赞:160收藏:38浏览:1859作品收藏:103

签名:what can i say

回复帖子评论
上一页6 页 / 共 8下一页

关于神岛首页改版的建议征集 中回复

把热力图放到个人主页

2022-02-10T19:50:23 点赞:0

【UP计划】第二期优质地图出炉! 中回复

又没我TAT~我好不容易参加一次,你却让我输得这么彻底~又快开学了

2022-02-11T11:24:55 点赞:0

【代码岛新春创作节】逃出玻璃笼 中回复

emm又被吃格式

2022-02-11T13:09:27 点赞:0

【活动】一起来,码上感受冬奥 中回复

center_image

助力冬奥,码上来

2022-02-12T09:36:56 点赞:0

【UP计划】第二期优质地图出炉! 中回复

自荐作品:https://box3.fun/g/278183

2022-02-12T11:35:02 点赞:0

一个大胆的想法 中回复

啊这。。。比什么

2022-02-14T14:43:52 点赞:0

说说各位对python的各类第三方库的熟悉程度吧 中回复

pygame会,easygui会

2022-02-14T15:20:36 点赞:0

【UP计划】第二期优质地图出炉! 中回复

逃出玻璃笼:https://box3.fun/g/278183

2022-02-14T20:56:30 点赞:0

up计划第一期创作倒计时两个小时,加油! 中回复

https://box3.fun/g/278183 我的地图

2022-02-19T13:16:03 点赞:0

(给新人看)如何制作电子钟 中回复

发错了(bushi

2022-03-06T09:43:27 点赞:0

如何添加注释!!训练师小课堂~~ 中回复

好水啊,这样的帖子一天可以出几百个

2022-04-15T20:21:43 点赞:0

无偿帮捏头像 中回复

az

 

2022-05-08T08:36:09 点赞:0

我在编创协赛事平台创建了一个比赛,快来报名! 中回复

test.bcmcreator.cn/index.php?mod=tests&t=1653136523

2022-06-03T21:44:34 点赞:0

我在编创协赛事平台创建了一个比赛,快来报名! 中回复

喵d

2022-06-04T08:12:31 点赞:0

我在编创协赛事平台创建了一个比赛,快来报名! 中回复

ddd

2022-06-04T19:39:32 点赞:0

【神岛干货】传送菜单代码 中回复

建议:switch()中的

selection.value

可以改成

selection.index

它表示选中选项在option数组中的索引。这样如果改了地名也能正常传送,

2022-06-04T20:32:02 点赞:0

【非官方比赛】神奇代码岛小测试,喜欢神岛的不要错过! 中回复

喵d

2022-06-05T09:55:57 点赞:0

【非官方比赛】神奇代码岛小测试,喜欢神岛的不要错过! 中回复

ddd

2022-06-27T13:39:33 点赞:0

不用F12就可以的无字天书! 中回复

     

2022-06-27T16:38:47 点赞:0

【非官方比赛】神奇代码岛小测试,喜欢神岛的不要错过! 中回复

ddd

2022-06-27T18:07:54 点赞:0

【非官方比赛】神奇代码岛小测试,喜欢神岛的不要错过! 中回复

ddd

2022-06-30T13:22:42 点赞:0

【非官方比赛】神奇代码岛小测试,喜欢神岛的不要错过! 中回复

通知:本次比赛的时间会延长1~2天

2022-06-30T15:49:43 点赞:0

谁会C++的给我站出来! 中回复

。。。吐了,我也略懂C++。。。

2022-06-30T16:35:35 点赞:0

【非官方比赛】神奇代码岛小测试,喜欢神岛的不要错过! 中回复

ddd

2022-07-01T15:21:36 点赞:0

【非官方比赛】神奇代码岛小测试,喜欢神岛的不要错过! 中回复

提示:原链接不可用了,新链接 competition.bcmcreator.cn/index.php?mod=tests&t=1653136523

2022-07-01T15:23:45 点赞:0

【神岛场景创作小技巧】猜猜这些动效是如何实现的? 中回复

《好耶,鸽子吉吉终于更新教程了》

2022-07-01T20:27:39 点赞:2

Box3作品代码公开-鱿鱼游戏之玻璃桥 中回复

ddd

2022-07-02T12:50:46 点赞:0

Box3作品代码公开-鱿鱼游戏之玻璃桥 中回复

 

createTable()
var a = []
console.clear()
async function createTable() {
    try {
        await db.sql`CREATE TABLE IF NOT EXISTS p (
        userName TEXT DEFAULT "",
        die INTEGER DEFAULT 0,
        won INTEGER DEFAULT 0,
        userKey TEXT PRIMARY KEY UNIQUE DEFAULT ""
    )`
    } catch (e) { world.say(`创建错误:${e}`) }
}
async function loadPlayer(entity) {
    try {
        const data = (await (db.sql`SELECT * FROM p WHERE userKey=${entity.player.userKey} limit 1`))[0]
        if (data) {
            entity.die = data.die
            entity.won = data.won
        }
    } catch (e) { world.say(`登录错误${e}`) }
}
async function savePlayer(entity) {//定义保存玩家状态的函数
    if (entity.player.userKey) {//拥有userKey的玩家, 则玩家不是游客, 可以保存
        try {
            await db.sql`
            INSERT INTO p (
                userName,
                die,
                won,
                userKey
            )
            VALUES(
                ${entity.player.name},
                ${entity.die},
                ${entity.won},
                ${entity.player.userKey}
            )
            ON CONFLICT(userKey)
            DO UPDATE SET
            userName=excluded.userName,
            die=excluded.die,
            won=excluded.won
        `
        } catch (e) { world.say(`保存错误:${e}`) }
    }
}
async function getTop100(n) {
    try {
        i = 0;
        x = [];
        if (n == '0') {
            for await (const row of db.sql`SELECT * FROM p ORDER BY die DESC LIMIT 100`) {
                i++
                x.push(`第${i}名:${row.userName},喵${row.die}次`)
            }
        }
        else if (n == '1') {
            for await (const row of db.sql`SELECT * FROM p ORDER BY won DESC LIMIT 100`) {
                i++
                x.push(`第${i}名:${row.userName},获胜${row.won}次`)
            }
        }
        return x
    } catch (e) { world.say('获取排行错误:' + e) }
}
createTable()
gamestart()
console.log(a)
a.push([120])
async function time() {
    for (let j = 30; j > 0; j -= 5) {
        world.say(`还剩下${j}秒`)
        await sleep(5000)
    }
    world.say('游戏结束!')
    for (p of world.querySelectorAll('player')) {
        if (!p.win) {
            p.hurt(100)
        }
    }
    await sleep(2000)
    gamestart()
    await time()
}
function gamestart() {
    a = []
    for (let x = 1; x < 49; x++) {
        for (let z = 10; z < 116; z++) {
            if (z % 5 != 0) {
                voxels.setVoxel(x, 29, z, 'blue_glass')
            }
        }
    }
    for (let z = 10; z < 116; z++) {
        if (z % 5 == 0) {
            if (Math.random() <= 0.4 + Math.random() * 0.2) {
                a.push([z, 0])
            }
            else {
                a.push([z, 1])
            }
        }
    }
    for (let z = 10; z < 117; z++) {
        voxels.setVoxel(25, 29, z, '')
    }
    a.push([120])
    for (p of world.querySelectorAll('player')) {
        p.hp = 100
        p.win = false
        p.position = new Box3Vector3(Math.ceil(Math.random() * 45), 32, 120)
    }
}
world.onInteract(({ entity, targetEntity }) => {
    entity.player.dialog({
        type: Box3DialogType.TEXT,
        title: '查看排行榜',
        content: `TA叫${targetEntity.player.name}TA喵了${targetEntity.die}次\nTA获胜了${targetEntity.won}次`,
        contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1),
        titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
        contentTextColor: new Box3RGBAColor(0, 0, 0, 1),
    })
});
world.onVoxelContact(({ entity, voxel, z }) => { //当触碰方块
    if (voxel == voxels.id('lava02')) { //如果方块类型是岩浆
        entity.hurt(100) //受伤
    }
    else if (voxel == voxels.id('red')) {
        if (!entity.win) {
            world.say(`${entity.player.name}获胜了!`)
            entity.win = true
            entity.won += 1
            savePlayer(entity)
        }
    }
    else if (voxel == voxels.id('blue_glass')) {
        if (entity.position.x < 25) {
            entity.q = [1, 25]
        }
        else {
            entity.q = [25, 49]
        }
        for (let i = 0; i < a.length; i++) {
            if (a[i][0] < z && z < a[i + 1][0]) {
                if ((a[i][1] == 0 && entity.q[0] == 1) || (a[i][1] == 1 && entity.q[0] == 25)) {
                    for (let x = entity.q[0]; x < entity.q[1]; x++) {
                        for (let z = a[i][0]; z < a[i + 1][0]; z++) {
                            voxels.setVoxel(x, 29, z, '')
                        }
                    }
                }
            }
        }
    }
})
world.onDie(({ entity }) => {
    world.say(`${entity.player.name}淘汰了!`)
    entity.die += 1
    savePlayer(entity)
})
world.onPlayerJoin(async ({ entity }) => {
    entity.enableInteract = true
    entity.player.enableDoubleJump = false
    entity.player.scale = 0.8
    entity.die = 0
    entity.won = 0
    loadPlayer(entity)
    entity.enableDamage = true
    entity.player.onPress(async ({ button }) => {
        if (button == Box3ButtonType.ACTION1) {
            x = await entity.player.dialog({
                type: Box3DialogType.SELECT,
                title: '查看排行榜',
                content: `你喵了${entity.die}次\n你获胜了${entity.won}次`,
                options: ['喵次数排行榜', '获胜次数排行榜'],
                contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1),
                titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
                contentTextColor: new Box3RGBAColor(0, 0, 0, 1),
            })
            console.log(x.index)
            if (x) {
                getTop100(x.index).then(async (v) => {
                    await entity.player.dialog({
                        type: Box3DialogType.SELECT,
                        title: '排行榜',
                        content: '排行榜(最多100名)',
                        options: v,
                        contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1),
                        titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
                        contentTextColor: new Box3RGBAColor(0, 0, 0, 1),
                    })
                });
            }
        }
    })
})
time()

2022-07-02T13:02:38 点赞:0

不会写代码 中回复

建议看书,自己翻网上的教程很难学会。

如果是Python的话给你推荐《父与子的编程之旅》,挺有趣的,就是有点厚,有点贵。。。

2022-07-02T20:58:03 点赞:0

【Kitten教程】如何画一个又大又圆的饼图? 中回复

有建议请提出来~

2022-07-19T10:01:57 点赞:0