Jump to content
  • Advertisement

Archived

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

dhscompguy

Using a quadtree in 2D?

This topic is 5867 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, First post so I hope I''m not breaking any rules. I apologize in advance if so. My question involves testing whether or not an object is in the vicinity of an explosion. Let''s say an enemy goes critical and explodes. This triggers an "explosion" event at his current x,y position. The event dispatcher is the first to hear of this. The dispatcher loops through every moving game object and checks whether or not the object is 200 units from the point of the explosion. If so, the object''s ID is pushed into a priority queue with a priority of distance. After these tests are done, the dispatcher pops IDs from the queue, nearest object to farthest, and calls gameObjects[ID].handleEvent(gameEvent). First off, is there a better way to handle this entire process? Secondly, would a quadtree be useful in this situation, where game objects are moving around every game tick and I want to see who is in a particular region at any given time, or would it be overkill (considering it''s a Flash game with very few game objects per level)? If overkill, any other ideas that might enable me to put a few more objects on screen at the same time? Thanks much, Denny

Share this post


Link to post
Share on other sites
Advertisement
Definitely overkill if you have very few objects... if the method you are using works, why bother changing it? Two rules to live by:

1) If it ain''t broke, don''t fix it.
2) Keep It Simple Stupid

Rule #2 basically means that you do the simplest thing possible that accomplishes the tasks.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!