PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Bouncing ball

Hey there,

I'd just like to see if anyone can quide me on how to bounce a ball off of an iregular surface, i'm trying to make a game but the areas is circuar (though it could be broken up into rectangular sections) and when a ball hits the wall i need to reflect the angle. Now i know there is a demo for detecting a collision, but could someone guide me on how to reflect the angle based upon a collision.

Any help would be apprechiated

grad
the reflection vector is usually calculated as

R = 2*(N.V)N-V

R = reflection vector
N = surface normal vector
V = view vector (in this case the direction vector of the ball

for a simple approach you can just invert ball coordinates, like for the pong game.. it jsut inverted x direction vector once it touched the play on the corner.. and the y coord once it touches the top or bottom of the screen..
hope it helps
Don't suppose you have a sample of it in action do you?

i know how to bounce it using the simple approahce but because of the iregular shape, i need to be able to detect what hits first the side of the ball or the top, then i could know what to reflect.

Pretty new to Gapi so if you expand a little more, i would really apprechiate it.