我在做一个游戏。在
游戏的世界由一个tilemap表示。平铺对应于二维数组中的值。在
我想使用一个特殊的“角落”墙精灵,如果任何三个墙砖使一个L形。也就是说
V
## # >##
# ## #
^
箭头所示的瓷砖应为墙角瓷砖。在
我有代码可以搜索墙,但我不知道如何识别哪些瓷砖是墙角的瓷砖。在
我的代码是:
^{pr2}$下面是指向精灵的链接: https://framadrop.org/r/fmReup_rTK#bMSywSUa7nxb1qL/a4FIbns+VaspgE0c/FU+9f1drHI=
https://framadrop.org/r/pBOfrnKcdT#eNEZQ9QjX5Cl6X4gH4UwdIg3eBPnY/L4WcSGYtUR5PE=
https://framadrop.org/r/ZFfTz_Lq9V#2Nd5ba1iE7miyFg8JpPFvwabAkdnHds/GfVkSAQeJaQ=
https://framadrop.org/r/gN9Y748L9G#Z552pPpgjTcSubt9tn74mZ0tT1COv7UCFdkUq2DorAU=
https://framadrop.org/r/d9k4hyCUni#OTza8UbsR8Am/R1PA9MAWkLDPRDBsT1rAHMgr61jusc=
https://framadrop.org/r/1mv777OR6d#pkqwaQrmVRElUPcdEV5K4UhmALsJSYX7z3WtrZXl4TE=
https://framadrop.org/r/CyF-tk7yUb#IFexcePe418JizElZzCJzDENTJPDfz7i1nr+lGns0rU=
https://framadrop.org/r/VzVfAz6bnL#oLHivyHPtTD8+IxliDD4yc+6LS9kpGyEp1HNFGUsBHo=
https://framadrop.org/r/0V0ShMH0uq#PZHdPSQNbgL7QqH2niwdS4HO34ZRMfIlhpvpRqbWwng=
我先生成一组偏移量
现在,我可以得到相邻墙的n值,如下所示:
^{pr2}$现在,我可以将列表转换为互动程序名称:
现在我只需要一堆名为的瓷砖,例如:
然后我可以说:
从评论来看,我不确定问题出在哪里。。。让我告诉你我会怎么做,这样我们可以在需要时进一步讨论:
编辑这里有一个简单(因此希望容易理解)的方法
为了使纹理干净,我首先必须旋转墙和角,以获得所有可能的配置(垂直/水平的墙,所有四种可能的角落)
^{pr2}$我创建了一个wall dict,用
in walls
快速检查墙的所有6种可能性然后我检查地图
我们得到了
请注意,有一些随机的墙壁配置看起来不太好,尽管(T形…),但这些将需要额外的精灵。在
我使用的完整代码可以找到here
EDIT2请注意,为了使一切顺利进行,您还需要更新一些内容(例如库存中的墙摄取) 另外,运行这个check every循环的代价很高,因此您应该声明一个
env_changed
布尔值,以便只在环境发生更改时进行测试。在对于库存,您需要
这使得VWALL成为库存中的默认墙,并且循环负责将其切换到一个合适的墙以供显示。 剩下的,嗯。。。这是你的游戏,所以我让你想办法;)
相关问题 更多 >
编程相关推荐