0

I'm trying to make a 2d platformer and I was wondering if a hash table is good for collision detection.

I want to have collision detection in a 2d game and I want the cod to not rely on graphics library's

genpfault
  • 51,148
  • 11
  • 85
  • 139
Brigaton
  • 11
  • 1
  • 1
    It's not immediately obvious (at least to me) how you'd use a hash table to do collision detection, even if you wanted to. A hash table is basically just a dictionary--it just lets you use a key to find some data associated with that key. I suppose if you assigned IDs to objects, you could use a hash table to find the data associated with an object ID, but this doesn't have relationship with collision detection. – Jerry Coffin Aug 29 '23 at 19:14
  • A crash table on the other hand, that sounds like it would be useful in detecting collisions... – user4581301 Aug 29 '23 at 19:31
  • Yes! Triangular and Quadtree decomposition are both recursive space-filling methods that *can* be used in determining collision. See this discussion: https://stackoverflow.com/questions/4981866/quadtree-for-2d-collision-detection – VoNWooDSoN Aug 29 '23 at 19:40
  • "Collision detection" in a hash table is likely not what you think it is. It has to do with two hashes resolving to the same value. Theoretically if you somehow hash the position and size of objects to somehow represent the boundary position between the two you could use hashes for physics "collision detection". In that case, the hash-table part would be irrelevant. – David C. Rankin Aug 30 '23 at 01:46

0 Answers0