Game Development Reference
In-Depth Information
Endless worlds and infinite space
There's really no such thing as endless or infinite in computer-generated worlds. Sooner or
later, you're going to hit one limit or the other. However, there are some techniques that
will get you further than others. The normal approach when creating a game is to move the
player around the game world. Those who have tried to, for example, make a space explor-
ation game in this way have noticed that pretty soon problems with regards to float num-
bers appear. This is because float values are not evenly spaced. As their values increase,
their precision decreases. Using doubles rather than floats will only delay what's inevitable.
If you can't even have a solar system as a human-scaled game world, how can you then
have a whole galaxy? As an old saying goes, "If Mohammed won't come to the mountain,
the mountain must come to Mohammed." That is exactly the solution to our first problem!
By making the game world move around the player, we ensure that the precision remains
high. This is great for large-scale game worlds. The drawback is that it requires a different
architecture. Switching how the game world is generated or loaded during the mid-devel-
opment stage can be a huge task. It's better to decide this during the design phase.
Another problem is the sheer size of the worlds. You can't simply store all the terrain-based
game world of a decent size in the memory at once. We can solve this problem by loading
world data on demand and throwing it away when we don't need it any more. This recipe
will use a simple method to generate the world on demand, but the principle can be applied
to other methods, such as generating a heightmap or loading the world from a storage
device.
Search WWH ::




Custom Search