How to make a 2d map with perlin noise python

落爺英雄遲暮 提交于 2019-12-11 06:28:10

问题


I have been experimenting on making a random map for a top down RPG I am making in Python. (and Pyglet) So far I have been making island by starting at 0,0 and going in a random direction 500 times (x+=32 or y -=32 sort of thing) However this doesn't look like a real image very much so I had a look at the Perlin Noise approach. How would I get a randomly generated map out of this :/ (preferably an island) and is it better than the random direction method?


回答1:


a perlin map can be generated easily.... it is simply a 2d array of values (typically 0 - 255) you just need to pick a threshold (say 126) anthing higher than that and render your land square. otherwise render water

something like this may help http://simblob.blogspot.com/2010/01/simple-map-generation.html




回答2:


You could also use 1d perlin noise to calculate the radius from each point to the "center" of the island. It should be really easy to implement, but it will make more circular islands, and won't give each point different heights.



来源:https://stackoverflow.com/questions/12232901/how-to-make-a-2d-map-with-perlin-noise-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!