Space Rocks – Fixing Collision Detection

Space Rocks – Fixing Collision Detection

For the past day I’ve been working on my asteroids-esque space shooter game and I’m at an impasse. I did get the laser shooting properly and most of the collision detection working. There are still minor things I need to implement, but that shouldn’t pose much of a problem. A simple start up & game over screen and a few other things.

A much more pressing issue is the collision detection between the laser and the spawned rock objects. For whatever reason, I can’t get it to work and it’s driving me crazy.

I have a class, LevelScreen, that handles initializing game objects. Within that class is an update method that calls an overlap method and handles the collision between objects. I use a for each loop to handle collision between the player’s ship and the rocks. This is different than the original code from the book which was giving me a class not found error. Or something along those lines.

When I try to use that same loop to detect collision between the laser and the rocks, it throws an error. After some googling, I tried the solution described here and while there are no errors, there is also no collision detection between the lasers and the rocks.

I do have one more idea for a solution which involves creating a second overlap method. This one will take in different parameters which should hopefully work with my original code. If all else fails, I do plan on posting on Stack Overflow or Badlogic forums. Which is something I haven’t actually done before.

I generally try to work things out myself and I know I need to get over the preconceived notions in my head about asking for help. I know there are plenty of people willing to help out there and I need to stop being so anti-social. More often than not though, I work out a solution on my own by looking at someone else’s posts and applying it to my own situation. I think I learn a lot that way.

Please follow and like us:

Leave a Reply