i am making a arkanoid like game and need help making the simple object detection between the ball and a block. i dont know how to determine which side of the block the ball hits.
i am making a arkanoid like game and need help making the simple object detection between the ball and a block. i dont know how to determine which side of the block the ball hits.
Drink Yer Wilk
ok, il make myself a little bit clearer:
i want to know how to determine what side of the block the ball hit like if the ball hit a side i would reflect the ball and mirror its x speed but the prob is is i dont know how to determine if it is in a certain side.
Drink Yer Wilk
This is how I solved it in my ball game:
Split every block into 4 parts (see picture below). When checking if the ball overlaps the block, also check which of the four triangles it is in. If it's in the top one, it's most likely the ball came from above. If it's in the left one, it's most likely it came from the left. And so on...
Obviously, this has some flaws if the ball's speed is too great, but may be a place to start.
You could also combine it with checking the ball's speed. If it enters the top triangle and the Y speed is going upwards there is certainly something wrong (the ball went through the block) .
Last edited by Magos; 04-17-2003 at 07:18 AM.
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Also, a theoretical solution I came up with is to "draw a line" from the balls last position to its current position. Then check which line of the block's four edges it overlaps. If none - no collision. If one - that's the side it collided with. If many - Check which edge was overlapped "first" (is closest to the last ball position).
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.