How do you change balls angle and not speed.
I know I probably aready know how to do this. But how would you
go about changing a balls angle on colision without changing
it''s speed? Yes I''m making a breakout clone. I just want to
be able to make the ball bounce off of the paddle at different
angles depending on where it hits the paddle. But I don''t want
to change the speed of the ball. Thanks for your time.
Foxtrot
you should have the x velocity and the y velocity.
if both the x and y velocities are the same, the angle will be 45 degrees. And the actual "speed" that you''re talking about is probably "r" which can be calculated by x^2 + y^2 = r^2. So what you want to do is makes sure r is the same when you change x-velocity and y-velocity. They angle is calculated using trig functions, for example:
if you want a 30 degrees angle with respect to the paddle you would do: (cos 30)r = x-velocity and y-velocity = (sin 30)r, to set your x and y velocity, and where r is the desired speed, in your case should be constant.
Get it?
if both the x and y velocities are the same, the angle will be 45 degrees. And the actual "speed" that you''re talking about is probably "r" which can be calculated by x^2 + y^2 = r^2. So what you want to do is makes sure r is the same when you change x-velocity and y-velocity. They angle is calculated using trig functions, for example:
if you want a 30 degrees angle with respect to the paddle you would do: (cos 30)r = x-velocity and y-velocity = (sin 30)r, to set your x and y velocity, and where r is the desired speed, in your case should be constant.
Get it?
Just to clarify...
To calculate speed.
(velocity_x ^2) + (velocity_y^2) = speed^2
Just the pythagorean theorem. Correct?
So if I want to bounce the ball 30 degrees. Figure out
velocity_y = (cos 30)*speed
velocity_x = (sin 30)*speed
Is this correct? Set the speed and make vx and vy changes
acording to the speed of the ball. Makes since to me I''ll give it
a try. Thanks for your help.
Foxtrot
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement