Sign in to follow this  

Zone & Quadtree system

This topic is 673 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

First, the game that I'm making, so far as this question is concerned, can be thought of as a 2D Zelda-style game. The maps are randomly generated, and I'd like movement between maps to be more-or-less seamless. One of the important mechanics, however, is sporadic memory loss, so maps that have been visited and then exited are re-randomly generated (once the player has gotten a reasonable distance from the area). 

 

Second, the game uses a component-entity-system design, and it's been working really well for me. I have a BoundsComponent that is essentially the AABB that fits into a quadtree and that system handles broad-phase collision detection wonderfully. Herein lies my problem, though.

 

How do I handle the quadtree across zones, especially during map generation? My current idea is to have each zone have its own quadtree that the player gets inserted into when she gets close enough and gets removed from the previous zone's quadtree once she's far enough away. This should allow me to generate maps that the player is not in in the background by clearing the zone's quadtree and re-inserting the map-tiles (or whatever the map is made of). 

 

I guess, more specifically, my question is whether or not this is a reasonable means of handling this situation. Is there a better way? Am I missing some really obvious solution?

 

Thanks for any insight you may offer!

 

Share this post


Link to post
Share on other sites
I would give each zone its own quadtree.

Unrelated to your question, but one possible way to have a world that is random, doesn't have to be stored in memory and persistent is to simply have a world seed. Whenever you generate a new world you assign a number. Each zone will have an x/y offset from the players starting position. You can use the world seed and the zone x/y to seed the random number generator when randomly generate each zone. That way it will generate the same content every time. Not sure if that would be desirable for your game but I thought I would throw that out there.

Share this post


Link to post
Share on other sites

This topic is 673 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this