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'd like to know how others have handled the issue of storing the entity's position. (Or maybe it's not an issue and I just make it too complicated.)

I'm undecided on whether to store the position of each entity in the world map file or in the entity's script file. From what I figured, both approaches have their own good and bad points:

If you store the entity's position in the map:

  • Good: Easier to edit the map; you can see where the entity will be. Maybe this isn't a problem for integrated map editors, but I'm using an external, general-purpose map editor (GLEED2D).
  • Bad: Inside the game it's easier to handle data if the position is inside the entity object, not the map object. So when you load the game, you have to gather data from a lot of places to build your entity object.

On the other hand, if you store the position inside the entity script, the advantages and disadvantages are exactly the opposite of the above.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

I would definitely store the position of entities in the map file. I mean, if you have multiple copies of the entity in your scene then you'd need multiple scripts that are identical except for the position; horrible! I consider that way more important than either of the points you mentioned.

share|improve this answer
    
That didn't occur to me. Seem like a no-brainer now. :D –  Paul Manta Sep 14 '11 at 13:59

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.