Jump to content
  • Advertisement
Sign in to follow this  
whaleyboy

Rotation question...

This topic is 5078 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

Here's another little problem I've just run into...how to make a stationary cannon 'aim' at the players sprite as it flies around the screen. I'm currently making a sidescrolling shooter by the way. Thanks to suggestions I've gotten earlier I've managed to get a bullet to shoot in the direction of a sprite but the cannon needs to point in the right direction for it to look right. I'm using GapiDraw so I can easily rotate the sprite, but don't know how to work out the angle. Thoughts? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
How are you working out the angle to fire your projectile along? You should be able to use the same angle as that to rotate the cannon sprite.

Share this post


Link to post
Share on other sites
First you have to calculate Dx and Dy,the distances in x and y axis between the cannon and the sprite.In C,you can calculate the angle in radians using atan2(Dy,Dx).Use the return value to rotate the cannon.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!