I am implementing space partitioning on the server for my top-down MMO game. In my demo I modified my algorithm from a space-hashing algorithm used to work fine on client side so it works like dynamic clustering. But the sprites/players are constantly moving so I will have to check every player for collision detection. Therefore the final array contains every sprites for collision check. This makes my space partitioning algorithm look redundant. And it is incredibly slow.
Here is how I do this:
- I pick a moving sprite from the sprite array
- do a spatial hashing for it and get some nearby sprites
- based on the above method, I loop through the entire sprite array and pick one by one to get some nearby sprites
- I put all the results into a big array and it will store all the sprite for collision detection.
Imagine I have 400 moving sprites on a 640 x 480 map. The real map may be 8 - 9 times larger though. But is there a better way to implement space-partitioning on the server without slowing the game too much?