2d Car Track Collision Response

Started by
1 comment, last by jHaskell 9 years, 7 months ago

Hello,

So, I am working on a 2d car game. For drivable surfaces, I was planning on using a bit map mask so I could determine if the road surface was drivable or not. However, anyone have any ideas on how to handle collisions, instead of saying cannot drive, I want to handle a collision, but I would normally need a normal of the face and then use that to bounce off of that surface. With a bit map, I just know they can't drive, how would I go about creating a normal from a bitmap?

Any thoughts?

Thanks

Advertisement

Is it top-down, or a side-scroller racing game?


how would I go about creating a normal from a bitmap?

You could try computing a least squares line using the local 'edge' points of your bitmap. By edge points, I mean those points in the mask flagged as collidable, yet adjacent to non-collidable points. As long as your bitmap maintains fairly smooth 'edges', I would think this would yield reasonable normals to use in collision response (those normals would, of course, be perpendicular to the least squares line that was computed).

This topic is closed to new replies.

Advertisement