Frage

I'm trying to create this game (break the wall) and I have a question : When the ball hits the paddle it's angle should change accordingly, but how? Any one knows and can help me?

thank you!!

War es hilfreich?

Lösung

As Soner wrote, it is impossible to tell without seeing some code. So this answer makes some assumptions that might or might not apply to your code. Anyway, the problem could be solved as follows:

Assume that we have the ball's direction and velocity as a vector. The paddle's normal will be a vector, too. Then you need to reflect the velocity at the normal with

velocity := velocity - 2 * normal * dot(normal, velocity)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top