How to optimize collision detection
Posted
by
Niklas
on Game Development
See other posts from Game Development
or by Niklas
Published on 2014-06-05T16:02:26Z
Indexed on
2014/06/05
21:44 UTC
Read the original article
Hit count: 372
I am developing a 2D Java Game with LibGDX. This is what it kinda looks like (simplified):
The big black circle is the player, which you can move by tilting the smartphone. The red circles and blue rectangles are enemies, which will move from the right of the screen to the left. The player has to avoid crashing into them.
Right now I am checking in the Game Loop every enemy against the player, whether they collide or not. This seems kinda inefficient to me, but I don't know how to improve it.
I have tried the Quadtree approach, but it did not really work. The player could easily glitch through enemies and the collision was not detected. Unfortunately, I have destroyed the Quadtree implementation. I used this [tutorial/blog] as my Quadtree implementation(http://gamedevelopment.tutsplus.com/tutorials/quick-tip-use-quadtrees-to-detect-likely-collisions-in-2d-space--gamedev-374).
© Game Development or respective owner