Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Space Fortress

Sign in to follow this  


collision detection.

so i had a thought yesterday, on my collision detection and response pains.

wait, lemme fill you in a little on what that means exactly. you see that crappy breakout below? yeah, well i was doing that because i needed collision stuff for space fortress. i thought, i think i want the same response from running into stuff as breakout has. as you might expect, detecting collisions between two rectangles was fairly easy - the problem was what to do with the information i had found out. i couldn't seem to get good results from rebounds, even with something as simple as breakout.

after a while, someone in #ludumdare suggested i use a movex-check/respond, movey-check/respond method. i was golden. then i tried the exact same code (cut&paste!) in space fortress. for some reason when you pushed up against the map, you'd zip along the other axis until you were around a corner. it didn't happen all the time, just when you were below a certain velocity and trying to get yourself flat against a wall. and even then it wasn't happening all the time, only along certain x or y values, like all along the top or all along the edge between tiley=31 and tiley=32. stupid stuff like that.

i'm still not exactly sure what it was about, but i'm guessing that it's an issue with floating-point error. and so i got to thinking: if we're dealing with tilemaps and sprites, why am i stepping outside of pixelspace? as long as i plan on using a 1:1 pixelspace:d3dspace conversion, why am i using sub-pixel tests and positioning? why not just trunc all my floats and deal with ints again? wouldn't that solve my problems, and make it a whole lot easier to think about these things in the future?

i didn't get any time yesterday after work to start this. i will be today, though. i'm hoping this will work out as i expect it to. don't get me wrong though! i still think that i need to use floating point values to store position and velocity. imagine trying to accelerate using only integers! no no, i'm only suggesting that collision detection and draw positions be pixel-aligned.

when i succeed (or fail horribly) i'll post more about this.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!