Generating 2d Rivers

Generating 2d Rivers

Rivers are really hard to generate for 2d top-down games for multiple reasons:

  • Rivers primarily form based on heightmaps which are hard to display in top-down
  • Displaying fluidity when working with sectors or grid-based rendering can be complicated, bresenham's line algorithm only goes so far to make things look smooth
  • naturally occurring mechanisms of nature have numerous factors in play that caused them to exist. Simulating all of these factors isn't reasonable.

I was able to make relatively decent 2d rivers using a few techniques.

  1. Started by having terminal points where rivers can start/stop. Primary start positions might be

Read More

Generating Ancient Ruins

Generating Ancient Ruins

While creating algorithms for random continent generation, I came across an old algorithm I had worked with called Coupled Map Lattice. Using that to create a continent was hard but I was able to accomplish it doing layers of filters:

  • generate map with noise between -1 and 1
  • apply CML using Spatiotemporal Intermittency settings
    • (a = 1.75, ε = 0.6)
    • I found that using something too chaotic didn't have a noticeable affect compared to just generating noise in general.
  • normalize values to between 0 and 255
  • apply a gaussian blur
  • normalize values to between 0 and 1
  • apply slight height

Read More

Object Collision With Spatial Hashing

Object Collision With Spatial Hashing

I ran across a great article today by Christer Bystrom that talks of the difference between Quadtree's and Spatial Hashing at implementation and subsequently alludes at the performance implications. I've made a more appropriate demo (in my opinion,) than the confusing code in the spatial hashing implementation on the page to make it more simple to see and understand. I thought that it was worth taking a look at. In my code example I do not show his spatial mapping library. You'll have to use this link to gain access to that. I merely show how I implemented the library.

Read More