Collision within a poly

Posted by G1i1ch on Game Development See other posts from Game Development or by G1i1ch
Published on 2012-03-16T21:39:05Z Indexed on 2012/06/15 15:28 UTC
Read the original article Hit count: 303

For an html5 engine I'm making, for speed I'm using a path poly. I'm having trouble trying to find ways to get collision with the walls of the poly. To make it simple I just have a vector for the object and an array of vectors for the poly. I'm using Cartesian vectors and they're 2d.

Say poly = [[550,0],[169,523],[-444,323],[-444,-323],[169,-523]], it's just a pentagon I generated.

The object that will collide is object, object.pos is it's position and object.vel is it's velocity. They're both 2d vectors too.

I've had some success to get it to find a collision, but it's just black box code I ripped from a c++ example. It's very obscure inside and all it does though is return true/false and doesn't return what vertices are collided or collision point, I'd really like to be able to understand this and make my own so I can have more meaningful collision. I'll tackle that later though.

Again the question is just how does one find a collision to walls of a poly given you know the poly vertices and the object's position + velocity? If more info is needed please let me know. And if all anyone can do is point me to the right direction that's great.

© Game Development or respective owner

Related posts about collision-detection

Related posts about JavaScript