collision - Prevent shapes from clipping into each other -
i started port game slick2d , want mine entities collide each other.
know shapea.intersects(shapeb)
checks if 2 shapes intersect want them collide aren't able overlap each other.
easy if shapes rectangles that's not case.
there way perform in efficent way?
hopefully got question right.
to need implement collision game. approach accomplish assume shape instance x coordinates head of current position.
this mean have check whether 2 shapes intersecting each other when moving, if intersect on next movement not allowed move head, otherwise intersect or collide. can adapt approach completly needs, example let them collide , set them not getting stuck each other.
there lot of tutorials regarding topic , different approaches, should check them out.
Comments
Post a Comment