Public Group

# Arkanoid ball/block collision question

This topic is 3687 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey, I'm making an Arkanoid clone. I'm using BoundingSphere/BoundingRectangle collision detection and it is working but I am just inverting the Y direction of the ball when it hits a Block. I want to be able to find which side of the Block the Ball hits so I can then determine the new direction of the ball (not just invert Y if there is a collision). Any help would be great :)

##### Share on other sites
incoming angle = atan2(vely, velx).

If you didn't want to use that you could switch to polar coordinates like so...

example: let ball have velocity of 6
float velocity = 6;

starting angle of pi
float angle = 3.14;

now, if you want to change the direction of the angle, just change "angle" to any angle you want, and if you want to change the velocity, set "velocity" to the new value.

determining new coordinates is very simple

new_x = old_x + velocity * cos(angle);
new_y = old_y + velocity * sin(angle);

Hope that helps, cheers!

##### Share on other sites
What I did when I was working on an Arkanoid clone was first check for a collision similar to how you are doing it. After I knew the ball was colliding with the brick, I did some calculations to find out where exactly it was colliding. The closer it was to the center, the steeper I made the y velocity (up to the negative-y change you are doing now).

Since you know the x and y positions of both the block and the ball it should be pretty straight-forward to find the position. Say take how far from the left edge of the brick the ball is.

I doubt this is the closest you can get to replicating actual arkanoid, but it worked for me.

1. 1
2. 2
3. 3
Rutin
23
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633653
• Total Posts
3013166
×