First something about my Project:
For a important school-work, we need to develop a game in Java. Since we are allowed to use Librarys, i decided to use SLICK2D/LWJGL to create my game (If you know a better one, say it ). My game is called BrickBreaker, a classic game in which you have to destroy Bricks with a paddle and a ball.
I solved nearly all my issues alone, but for this one, i can't find any answer:
To get the collision detection working, when the ball hits a Brick, i have to check which side was hit by the Ball. I achieved this with creating a Line on each side, and then i check if the line collides with the Ball and return the code for that direction (e.g "south","west").
This works at the most collisions, BUT:
Since i hava a Circle Object as ball, i also can happen, that the Ball collides with 2 lines of a Brick, e.g if he hits a corner of a Brick. Then, the ball goes in that direction, which was checked first, and often thats unrealistic and looks ugly.
Steps which i already tried:
Storing all collisions with the lines in an ArrayList, and then checking if the ArrayList contains 2 Directions. If so, turn the Ball 180°.
Works at all, but there are moments where it totaly looks crappy:
The ball would turn around 180°, but normally he should just go down. ( it collides with north and east)
I hope you can understand my Problem, if not, i will post more Infos.