Map Generation for Animal RescueThis animated gif (click on it to view) shows how the map is dynamically generated as you play, with the new map section scrolling in from the top while the bottom sections are removed and recycled.
The map is divided...

Map Generation for Animal Rescue

This animated gif (click on it to view) shows how the map is dynamically generated as you play, with the new map section scrolling in from the top while the bottom sections are removed and recycled.

The map is divided into chunks that are loaded above the visible screen area layer by layer, starting with the ground tiles, the trees, then the yellow animals and safe zones (the yellow boxes) where you deposit the animals in your tail.

The layout of each chunk is generated using a cellular automata algorithm to create interesting patterns can look like organic caves or rooms, as this image from Jeremy Kun’s post shows.

However, as you can see, some of the areas are isolated, which we need to join together if we want a continuous path for our snake. We do this first by detecting all the areas and performing some operations on them, such as removing those that are too small or merging them with their neighbors. Then we draw thick lines to connect nearest neighbors to create corridors.

Finally, because our game has to scroll forever, we need to ensure that the top and bottom areas of each map chunk also have a continuous path between them.

In our next post, we’ll talk about how we fill the map to make gameplay more interested.

Notes

  1. animalrescuegame reblogged this from cabalentertainment
  2. cabalentertainment posted this