二维瓦片地图生成 [英] 2D tile map generation

查看:40
本文介绍了二维瓦片地图生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 2D 切片引擎,目前我正在研究地图生成算法.

I'm developing a 2D tile engine and at this moment I'm working on map generation algorithms.

我尝试了通常涉及简单高度图生成的基本方法,例如

I tried the basic ones usually involved in simple heightmap generation like

  • 山地生成
  • 柏林噪声
  • 菱形方块

但我总是遇到同样的问题:这种算法在处理也有高度分量的瓦片地图时似乎很合适,但这不是我的情况.

but I always get the same problem: this kind of algorithms seems suitable when dealing with tile maps that also have a height component but this is not my case.

我基本上有草、海、沙漠等精灵,但它们不应该根据生成的高度放置在地图内,而是像

I basically have sprites like grass, sea, desert and so on but they shouldn't be placed inside the map according to a generated height but something like

  • 一切从海洋开始
  • 岛屿位于地图中间(这是我尝试的算法最失败的地方)
  • 产生沙漠(它们应该像周围的随机点)
  • 生成山脉和丘陵链(它们应该像蛇一样)

我应该尝试什么样的方法?

What kind of approach should I try?

我通过开发专门的算法来解决子组件问题(如沙漠、丘陵和山脉)来做我需要的事情(例如,山从一个点开始,然后跟随一个有机会转弯的方向),但我失败了基本岛的生成(可以自定义为只是一个泛大陆或许多度数的大小).

I solved the subcomponent problems (like deserts, hills and mountains) by developing specialized algorithms to do what I needed (for example mountain starts from a point and then follow a direction with a chance of turning) but I'm failing with the generation of the basic islands (which could be customizable to be just a pangea or many degrees of size).

只是为了给你一个实用的想法,我正在寻找类似于文明算法的东西:

Just to give you a practical idea what I'm looking for is something like the civilization algorithm:

推荐答案

[山丘生成、柏林、菱形方块] ...这种算法在处理也具有高度分量的瓦片地图时似乎很合适,但我的情况并非如此.

[hill generation, perlin, diamond square] ... this kind of algorithms seems suitable when dealing with tile maps that also have a height component but this is not my case.

但这是你的情况.山高于平原,平原高于水.

But it is your case. Mountains are higher than plains, and plains are higher than water.

                        ___/
                    ___/ ___ Mountain cutoff
                ___/
         ______/
    ____/ ___ Water cutoff
__/

您可以量化您的数据,如果它在一组级别之间,则将其计为一种类型的磁贴,而当它在不同的范围内时,则属于不同类型的磁贴.您将丢弃一些细节,但您仍会获得与您生成的噪音类型相匹配的轮廓.

You can quantize your data so that if it is between one set of levels, it is counted as one type of tile, whereas when it is in a different range, it is a different type of tile. You'll be throwing out some detail, but you'll still get outlines that match the type of noise that you're generating.

这可能需要进行大量调整,并且需要您自己生成其他陆地特征(除了不可逾越的山脉),但您必须对任何内容生成解决方案进行大量调整.

It'll probably take a good amount of tweaking, and will require you to generate other land features (besides impassible mountains) yourself, but you'll have to tweak a lot with any content generation solution.

这篇关于二维瓦片地图生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆