Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing a procedural terrain class at the moment and am stuck on the correct design pattern. The terrain is 2D and is constructed from a series of (x,y) points. I currently have a method that just randomly adds points to an array of points to generate a random spread of points. However I need a more elaborate system for generating the terrain.

The terrain will be built form a series of re-accuring terrain structures eg. a pit, jump, hill etc. Each structure will have some randomness assigned to it, each height of hill will be random, pit size will be random etc. Each terrain structure will have:

  • A property detailing the number of points making up that structure (not absolutely necessary)
  • A method for generating the points

My current thinking is to have a class for each terrain structure, create a fixed amount of terrain elements ahead of the player, loop over these and add the corresponding points to the game.

What is the best way to create these procedural terrain structures when they are ultimately just a set of functions for generating terrain elements? Is a class for each terrain element excessive?

I'm developing the game for iphone so any objective-c related answers would be welcome.

share|improve this question

closed as primarily opinion-based by Josh Petrie Dec 16 '14 at 2:41

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.