猫史档案馆


游戏咋档存记录

用户:奥利给分隔符奥利给分隔符查看:5 回复:4 评论:5 创建时间:2020-05-30T19:04:21


我想编写可以档存记录的游戏,代码咋整


回复

上一页1 页 / 共 1下一页
SCI氢氧化钡SCI氢氧化钡

私有云变量

点赞0


评论


奥利给分隔符奥利给分隔符

发个图片

谢谢

点赞0


评论


雪月灵狐吖_0927雪月灵狐吖_0927

发现一只猫妖

emotion_奥特曼emotion_肥皂emotion_炸鸡和啤酒emotion_西瓜emotion_dogeemotion_喵喵

点赞0


评论


DoooooveDooooove

第一种:模型存档

//存档点:可放置多个,需要加存档点标签,同时存档点需要开实体化,可推移要关掉
world.querySelectorAll('.存档点').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        if(other.player.Start==true){
            other.player.spawnPoint.copy(other.position);
            other.player.directMessage('存档成功!')
        }
    })
})

第二种:方块存档(踩S存档)

world.onVoxelContact(({voxel,entity})=>{
const c=voxels.id('S');//也可以是别的方块
    if(voxel===c){
        entity.player.directMessage('存档成功!);
        entity.player.spawnPoint.copy(entity.position);
    }
})

2、起点的提示(加起点标签,开实体关防推移)

world.onPlayerJoin(({entity})=>{
    entity.player.Start=false;//跑酷起点判断,防作弊
    entity.enableDamage=true;//可伤害
})
//跑酷起点
world.querySelectorAll('.起点').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        if(other.player.Start==false){
            world.say(other.player.name+'出发了!');
            other.player.Start=true;
            other.player.spawnPoint.copy(other.position);
        }
    })
})

3、不想说了太简单,一行就可以了

//跑酷快速传送门
world.querySelectorAll('.跑酷传送门').forEach((e)=>{e.onEntityContact(({entity,other})=>{other.position.set(124, 23, 68);})})//填自己的坐标,标签跟前面一样,怎么做就怎么做

4、一样的简单,也是1行(才怪)

world.querySelectorAll('.终点').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        other.player.directMessage('你到了终点!获得加速效果!(蹲下加速)以及发光!')
        world.say(other.player.name+'到达了终点!')
        other.player.Start=false;
        other.player.emissive=999;
        other.position.set(73, 10, 77);//这里填出生点坐标
        other.player.spawnPoint.copy(other.position);
    })
})

5、需要配合上面代码

//如果玩家跑酷中,一到地上就凉凉
world.onTick(({entity})=>{
    world.querySelectorAll('player').forEach((e)=>{
        if(e.player.Start==true){
            if(e.position.y<=15){
                e.hurt(999)
            }
        }
    })
})

如果连起来,就是:

//跑酷起点
world.querySelectorAll('.起点').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        if(other.player.Start==false){
            world.say(other.player.name+'出发了!');
            other.player.Start=true;
            other.player.spawnPoint.copy(other.position);
        }
    })
})
//存档点:可放置多个,需要加存档点标签,同时存档点需要开实体化,可推移要关掉
world.querySelectorAll('.存档点').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        if(other.player.Start==true){
            other.player.spawnPoint.copy(other.position);
            other.player.directMessage('存档成功!')
        }
    })
})
//如果玩家跑酷中,一到地上就凉凉
world.onTick(({entity})=>{
    world.querySelectorAll('player').forEach((e)=>{
        if(e.player.Start==true){
            if(e.position.y<=15){
                e.hurt(999)
            }
        }
    })
})
//跑酷快速传送门
world.querySelectorAll('.跑酷传送门').forEach((e)=>{e.onEntityContact(({entity,other})=>{other.position.set(124, 23, 68);})})

(这里用了模型存档)

点赞0


评论