Hello friends;
I am working on an rts game where player (and the computer) each might have up to a few hundreds of units. (I know, it sounds like bad design, but it's not, you will believe me when I show you the game:))
And since most, if not all, units will need to react to enemy units when they are in range, I will need a real or pseude collision detection between the few hundred player objects and few hundred computer objects. Add to that the terrain pieces, which is a rather large terrain by the way, and you see I got myself in trouble. I am not even mentioning that each player unit currently doesn't check against collision for eachother, so they are able to pass through eachother.
Now, I have tested this up to a 300 player units against 50 terrain objects and pc is able to handle this very well. But beyond this it will become bad, and I will not be able to expand.
After some research I am convinced quadtrees may help me here. I have read some posts by Ashley where he says collision performance is on to do list but low priority. But I think I can create my own quadtree system via events and thats where I need help.
First, check this beauty up:
mikechambers.com/blog/2011/03/21/javascript-quadtree-implementation
Now, then, any idea where / how to start :)
EDIT: or this spatial hashing, which looks easier to implement:
conkerjo.wordpress.com/2009/06/13/spatial-hashing-implementation-for-fast-2d-collisions
Kind regards and thanks in advance;
-Wind.