Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

1 Answer 1

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
1  
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

 
discard

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.