Search code examples
javaslick2dcollision

I cannot seem to find an answer to finding the point of collision between two objects with slick2d


I can find IF two objects collide, but not the point in which they DO, I have seen other posts asking similar questions, but the answers have always been too cryptic/made large assumptions on the knowledge of the user, and were always for other languages. I am working on a program where a person launches a pipe Bomb, the speed and displacement accounting for rotational velocity, gravity, air resistance, and mass. In my scenario there are only two times at current, in which an actual collision can occur: first when the pipe bomb hits one of the four walls and second, when the object hits the explosion of another pipe bomb.

Theoretically I can figure out how to do collision for the pipe bomb and a wall (The pipe bomb 's collision is a square) because the pipe bomb can only collide while facing completely perpendicular to the wall, parallel, or hitting on one of its four corners (I could figure this out using the rotation of the pipe bomb). When I try to figure this out when the pipe bomb hits the circular explosion of another pipe bomb I'm stumped, because theoretically it could be anywhere on any side of the pipe bomb because a circle doesn't have flat edges.

My plan was to find the point on the pipe bomb where it intersected anything, get the radius from the center of mass of the pipe bomb, and find the torque from the force being applied by the explosion (Which radius increases as time goes up, but force decreases until it hits zero, and it disappears), or the inverse force from the ricochet off of the wall.

Below WOULD have been a image that shows two moments of collision in my program to show my point, but I apparently can't do that yet...


Solution

  • Since the wall is basically a vertical line, you can just use this as a guide for predicting the point(s) of collision.