Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

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 have some game objects that are always at the same position in my game world as they make up some of the scenery of my puzzle game. At the moment, their positions are sort of hard coded in and some of their positions are calculated relative to the hard coded positions of other objects at the time of game initialization. This has been hard to maintain because whenever I've decided to change the position of these scenery objects as the game design evolved, I have to go and rewrite parts of the code that place the created objects and calculate their positions in the world.

Is there a more maintainable way of handling the positioning of fixed game objects?

share|improve this question
up vote 4 down vote accepted

Yes, store their position, and really any other data about them that you might wish to change at some point in some sort of configuration file that the game reads at start up. Generally I've found a good rule of thumb is that if anything in the code is referring to a specific instance of something, it is worth considering moving that out of the code.

share|improve this answer
Might be worth mentioning the term "data-driven design" as that's what you're talking about here. And yes, it's always a good idea. – Sean Middleditch Mar 18 '12 at 23:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.