Sign in to follow this  

Tile based game question @ the server level

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

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