Water Flow Mechanics

Water is an aspect that I spent quite a bit of time on. In the current version, above-ground water “seeps” into a cell until that cell is fully saturated. Then any remaining water runs a test on its adjacent cells, and if it finds a cell with a lower water level (taking into account cell height), the water will travel to that cell. So basically, water is designed to flow quite naturally.

In the above video I’ve set one of the cells to produce a unit of water at each update. The numbers represent the amount of unsaturated water in each cell. As you can see, water is moving towards the left side of the map, which is at a lower height. Before a water unit flows into an adjacent cell, a check is performed to determine whether the water should be used to saturate the cell. If so, then the water unit disappears and the cell gains a saturation level.

Evaporation also occurs in the game. It slows the spread of the water and causes small puddles to eventually disappear. The puddle created in the video above will eventually reach an equilibrium between the rate of water creation and the rate of evaporation. At this point it will stop expanding. Larger ponds with enough water units in each cell will be immune from evaporation, although I’m thinking of changing this in the future if it benefits gameplay.

By |June 21st, 2013|GameDev, Map Generation|0 Comments

Generating the Game Map

Ok!

As I mentioned in the last post, I’ve been working on this game for a while so I’ll introduce a different aspect of the game in each post. The whole thing is still a work in progress so anything I say could be changed eventually if I find a better way of implementing a mechanic.

The first thing I needed to do was build a map for all the game objects to live on. The game map consists of a set of 2D tiled hex cells. Each cell contains information on its level of topsoil, rock, organics, saturation, water, height and temperature. When combined, all these variables can be used to determine the type of ground currently present on a cell, which in turn will affect the types of plants that can grow and resources that can spawn there. For example, a cell with high topsoil levels will allow a tree to grow, while a rocky cell will be more likely to spawn boulders.

To determine the level of rock, organics and height in each cell, I’ve created a random map generator that uses Perlin noise. Behold the result:

080613a

As you can see, the worlds generated consist of dense forests with open rocky areas. It should be easy to generate other types of worlds by tweaking the random map generator. For example, a less forested world could be created by lowering the overall level of topsoil. I’ll get around to implementing other world types eventually, but for now this is a good foundation for the game. Next time I aim to post about the mechanics of water and water flow.

If you have any questions or would like to know more, please post in the comments!

By |June 9th, 2013|GameDev, Map Generation|0 Comments