Sign in to follow this  

Rotation question...

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

This topic is 4866 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this