Polygon Map Generation demo
来源:互联网 发布:linux ssh连接数限制 编辑:程序博客网 时间:2024/06/05 06:20
http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/
The simplest way to explore the maps is to click Random repeatedly. Try the various Island Shape, Point Selection, and View options.
Feel free to use these maps for any purpose, including commercial use. This is a map generator I wrote in 2010 for a game; I’m not working on it anymore, but all the code is available so that you can download and modify it for your own needs.
In a shape number like 85882-8
, 85882 chooses the overall island shape and 8 is the random number seed for the details (random points, noisy edges, rivers). You can type in a shape number and press Return to generate that map. The details will vary based on the other options you’ve selected.
I wrote an article describing the algorithms, and how you can use all or some of the parts in your own projects. I generate island maps with constant slopes here, but you can use the same ideas for many different styles of maps. Notes:
- Radial, Perlin, Square, Blob are about the island shape.
- Random, Relaxed, Square, Hex are about how the map is divided up into polygons.
- Using 4000 or 8000 points can be slow. I’ve tried 16,000 but Flash gets rather buggy so I didn’t put it in the demo.
- The PNG output is 2048x2048, and draws the selected mode (biomes, polygons, 2d slopes, etc.). It’s slow. I don’t include the noisy bitmap dots so that you can more easily use this in your own projects.
- The byte array output are a 2048x2048 height map, a 2048x2048 moisture map, and a 2048x2048 array of bit flags, which you can decipher by looking at
exportOverrideColors
inmapgen2.as
. - The 3D slopes output is slow (I wrote this a long time ago, before GPU acceleration was generally available in browsers).
- There are lots better ways to render the maps, but I haven’t explored them. For this project I was focused on the generation of structured maps.
- I also implemented road and lava algorithms but didn’t include them in this demo.
- The watershed detection algorithm is unifnished. I was hoping it would be useful for assigning territorial control. I will revisit it when I want to procedurally generate towns, cities, nations, histories, etc.
The code is open source, using the MIT license (allows commercial use). I put it up on Github. Sorry, it’s not designed to be easy to reuse. I focused instead on explaining the concepts in the article, so that you can implement the algorithms yourself. I did not implement the Voronoi algorithm; I used an existing library for this.
The original demo I posted in 2010 is here. Changes: I took out roads; I added PNG export; I added byte array output (e.g. height maps); I added control over the number of points; I added control over the distribution of points.
- Polygon Map Generation demo
- Google map draw polygon
- 【HDU 6055 Regular polygon】+ map
- BingMap改变鼠标样式【Map/Pushpin/Polygon】
- polygon
- Polygon
- Google Map Demo
- Game Map Demo
- STL map demo
- Map的排序Demo
- Android Map demo
- Google Map Api V3 系列之 Polygon 获取中心点方法
- How the Procedural Map Generation Works in Reactor Heart
- 地图程序生成研习会Procedural Map Generation Workshop
- iPhone 3D map Demo.
- STL容器使用DEMO-map
- java Map对象排序demo
- json转map参考demo
- java异常类子类和父类的关系
- 代码干货|零基础学Python,送你一份吊炸天的学习步骤与规划
- 获取Cocos Studio制作的层
- android是什么意思
- windows 遍历文件夹
- Polygon Map Generation demo
- 粒子特效
- PHP 数组玩法
- 三目运算符的使用? :
- python学习查漏补缺
- 打印金字塔
- G
- element.querySelector() 和 element.querySelectorAll()
- 防逆向技术简史:从代码混淆到虚拟机保护技术