简体   繁体   English

2D 平台游戏程序世界生成器

[英]2D Platformer procedural world generator

i am currently developing a 2D tile based java platformer.我目前正在开发一个基于 2D tile 的 java 平台游戏。 Not to earn money, just for fun.不是为了赚钱,只是为了好玩。 Recently i found this game called Caveblazers.最近我发现了一个叫做Caveblazers的游戏。 It is a 2D platformer too and i think it is also tile based.它也是一个 2D 平台游戏,我认为它也是基于瓷砖的。 It's world is procedurally generated and looks different everytime you play the game.它的世界是按程序生成的,每次玩游戏时看起来都不一样。 I tried to experiment with perlin noise and simplex noise, but it didn't work out as planned.我尝试尝试使用柏林噪声和单纯形噪声,但没有按计划进行。 I couldn't even make sure, that the level is possible and there are no walls obstructing the goal.我什至无法确定关卡是否可行,并且没有墙壁阻碍目标。 My game is going to be a lan based game, also in caves.我的游戏将是一个基于局域网的游戏,也在洞穴中。 So my question is how to generating these awesome looking caves and how to get locations to place scaffoldings and chests.所以我的问题是如何生成这些看起来很棒的洞穴以及如何获得放置脚手架和箱子的位置。 Help would be very appreciated and since it has to be playable until next week, i would love to get a quick answer!非常感谢帮助,因为它必须在下周之前播放,我很想得到一个快速的答案!

That is how i would like it to be:这就是我希望它的样子:

Think of perlin noise as smooth more or less boring terrain heightmap.将柏林噪声视为或多或少无聊的平滑地形高度图。

Values generally range from 0 to 1, or -1 to 1.值通常在 0 到 1 或 -1 到 1 的范围内。

First test your perlin noise code in a separate application / UI, just with colors or 3 tiles, once you master this try mapping to better tiles.首先在单独的应用程序 / UI 中测试您的 perlin 噪声代码,仅使用颜色或 3 个图块,一旦您掌握了这个尝试映射到更好的图块。

https://www.redblobgames.com/maps/terrain-from-noise/ https://www.redblobgames.com/maps/terrain-from-noise/

The mapping is up to you, but in general what would be hills in the heightmap are walls in your 2d platformer and deeper points are left empty/transparent or filled with background tiles.映射取决于您,但通常情况下,高度图中的山丘是您的 2d 平台游戏中的墙壁,而更深的点则留空/透明或填充有背景图块。

In addition to this you will want to ensure passage maybe using some bot which checks that the caves are passable , the bot may carve some extra smoothed passages using additional code.除此之外,您可能需要使用一些检查洞穴是否可通过的机器人来确保通道,机器人可能会使用其他代码雕刻一些额外的平滑通道。 You cannot achieve this with pure perlin noise so this second step is more art than science.您无法使用纯粹的柏林噪声来实现这一点,因此这第二步与其说是科学,不如说是艺术。 In general the code carves tunnels into the perlin noise by averaging values to avoid rude edges.通常,代码通过对值求平均值来在柏林噪声中挖出隧道以避免粗略的边缘。

May be use something like random walk + some direction, see: https://gist.github.com/jeffThompson/5608847可能使用类似随机游走 + 一些方向的方法,请参阅: https : //gist.github.com/jeffThompson/5608847

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM