Quote:Original post by Hunter_Ex
u have some points but the sorting also takes time.
what u think about making a game with linked list's??
yea, sorting takes time, which is why i said keep only static collision objects in that data structure - you only sort once when the level is loading.
for example in the game of elastomania (i think thats what its called, the 2d motorcycle in a polygon world) i would try to sort the polygons somehow so i can check collision with them fairly quick, while if i had moving objects (saying boxes you can push, or moving platforms or moving enemies) i would put it in a different unsorted datastructure (either array or linked list). for collision i would then check both the sorted and the unsorted.
as for the question of array or linked list - the choice depends on how much you need to insert/remove from the structure and how much you need random access. For collision detection you dont need any random access (you loop checking for each so can do it one after the other) so linked list works fine, and the only advantage you gain from array is that its abit simpler to program. so if you dont add/remove alot you can choose array.
Linked list is my choice since in array as people suggested you might have say 500 cells and 499 empty cells but you still need to check all of them - not elegant.
but as i said first - you should start from simplest approach and fix it later if you find it too slow (i doubt you will feel slowness).
Iftah.