# Procedural Generation of Infinite Level

What are some good approaches to procedurally generating an infinite 2d level? The level could be constrained in either dimension but not necessarily.

The approach that makes most sense to me so far is using a grid-based radius. e.g. divide the play area into a grid with squares of a certain size and then load X squares in a radius around the player. Then when the player moves to another square build the next set and drop the farther (Persisting explored area is not necessary.) When a square is built, it contains a random arrangement of objects. When objects leave the outer ring of squares they are removed from the world. Are there better or different ways? Or if this is a good approach, what are potential issues?

For discussion's sake, you can think of the level as a top down asteroid field with power ups, etc scattered throughout.

• This seems to be related: gamedev.stackexchange.com/questions/2230/… Commented Aug 9, 2010 at 20:42
• ^ and thus it is in the "Related" column on the right side. No need to link. Commented Aug 9, 2010 at 20:53
• And then it became "linked" as well as "related" - neat, huh? :) Commented Aug 9, 2010 at 20:54

• Also be aware not just of integer wrap-around but of inaccuracies of small floating point changes when the floating point number is high. Try this: float pos = 1000000000.0f; float nextPos = pos + 0.001f; float diff = nextPos - pos; On my machine, diff is 0. Commented Aug 10, 2010 at 8:28