Smooth Caves
Click that "generate" button to create caves to your heart's content! Tweaking the settings can be fun too.
Not sure what I'll use this for yet. I was just in the mood to make some caves, and PROCJAM came along at a convenient time. It wouldn't surprise me if this exact combination of algorithms has been used before, but I learned a lot while building this, so I feel like it was a success.
The code is available on codesandbox.
Methodology & credits:
- Plot random points
- Get Delaunay triangles of those points using mapbox's delaunator
- Use the centroids of the Delaunay triangles to map the cells, instead of traditional Voronoi mapping
- Randomly assign each cell to either "wall" or "path" proportionally (approximately) according to the setting
- Combine path cells to create path shapes
- Smooth shapes using Chaikin’s Algorithm
Packages used
References used
Status | Prototype |
Category | Other |
Platforms | HTML5 |
Author | mapsandapps |
Comments
Log in with itch.io to leave a comment.
Thanks for the clear explanation of the process!
Now, we are ready for a game of worms!
Loving the results! Would be cool in a simple lunar lander type game.
Good explanation of the algorithm. The "extra info" setting really helped me understand how the caves were generated. Seeing the SVG code is also nice.