Advertisement Jump to content


This topic is now archived and is closed to further replies.


storing and representing a game universe: how??

This topic is 6173 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all, I have a question... hopefully you can give me some insight! I''m attempting to build a small game, and I''m pondering the question of storing the positions of all the objects in it. My idea is a space based game (so no terrian, per se). The real problem is updating each objects position (enemy ships, asteroids, etc) each frame. My first idea for how to store the items in the world would be a linked list or stl vector. However, that means that I have to iterate through every item in the world each time through the loop to see if I should draw it. Then I thought, maybe a "sliding window" thing where the items within a certain distance would be in a vector that is the "draw me" list and everything else is in the "update & do not draw" list. That didn''t eliminate the problem, because I''d still have to go through every item in the list. Don''t you have to go through each item, each time? I also thought about having a third list that holds all stationary items because they don''t have to be updated, but once again, still have to be checked if they are viewable. Recently, I''ve been reading about quadtree''s but don''t exactly understand them. My first question is, would this be the solution? If not, what could be a solution? Anyway, back to quadtrees. Say I actually understand what it is and how to implement(which I don''t yet), how do you tell which regions are within view in order to draw only the items in those regions? Also, how do you link the objects to that region? I know this is a huge question, but I''m just starting so I''m not too sure of even where to begin. Thanks for any help you can give me.

Share this post

Link to post
Share on other sites
This isnt much of a reply, but dont you *need* to update moving objects every frame? Unless they had constant velocity or another easily defined position function, in which case:

old pos += (velocity vector)*(current time - last active time)

this could be used if you have a massive universe you''re trying to keep track of and the object is not going to come in sight anytime soon, but you would still have to calculate this every once in a while

even with this easy movement, good luck with collision detection without updating frequently

Share this post

Link to post
Share on other sites
actually, the calculation of position with time passed was another strategy I considered. however, i think we both thought of the same problem (or variations)....

you mention collision detection will be off, i thought the actual positions would be off... if they are only updated rarely, would it be possible for them to be offscreen, then blam, suddenly appear onscreen? i would guess not really, because computers are so fast...

would this be the way to go then? do a static 4 mod 4 at the beginning of the update code and then only run it once every 4 loops or so, unless they are onscreen?

back to the octree/quadtree question... can you use them to hold objects with motion? if this were a first person shooter, i wouldn''t see a problem (yet) but with objects moving, they would have to detach and reattach to the tree.... isn''t that expensive/bad??

thanks again!

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!