Jump to content
  • Advertisement
Sign in to follow this  
luzarius

Tile based game question @ the server level

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

Tile based game question @ the server level Two types of obstructions (Things you can collide with) 1) Static - Rock,Wall,Lightposts, (always stay in the same spot) 2) Dynamic - Players, npcs (always on the move) Is it better to keep these things in two seperate objects when searching for possible collisions? For example I'm using a dictionary object that represents a zone in my game world. The dictionary object has a list of both static & dynamic obstructions. The problem is when I want to just search for players I have to also loop through the static objects, thus increasing the loop time. What do you think? Seperate them into different tables? One table for static obstructions and one for dynamic obstructions? Luzarius

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure exactly what a "Dictionary" object is - I assume, some sort of associative array.

If you have a large world and/or many objects, it's likely that you'll want to arrange objects spatially somehow.

The easiest way of doing this is using some kind of block map and then when testing for collisions, only check blocks with overlap with the object.

You could choose to make the block 10x10 tiles for instance (Ideally, make it bigger than the biggest object, so that an object can't be in > 4 blocks at once).

Then have a list of objects within each block. When an object moves, consider which block(s) it's now in, and update this as necessary.

This is inherently pretty scalable because you'll never have to collide-test every object in the world.

----
Other people will suggest using quadtrees etc, but they are really much more complicated to implement. Go with the simplest solution.

Mark

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!