Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Breakout clone, ball´s moving

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I´m working out with Breakout clone (C++/OpenGL) and now I need some help with figuring out how to move ball correctly. Ball has a variable angle (direction). Question is: How can I increase/decrease ball x and y variables correctly based on this angle variable? Thanks.

Share this post

Link to post
Share on other sites
I don't know openGL, but if you know the angle you want the ball to travel in, and the total velocity, then x_increment = velocity*cos(angle); and y_increment = velocity*sin(angle);

that will give how much x and how much y to move it by every time to move in that angle. The angle will probably have to be in radians. If you're not familiar with radians, the formula for degrees to radians is r=(pi/180)*d .

You'll have to find a way to save precision among the types you're using.

[edited by - masque01 on March 21, 2004 1:39:14 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!