Sign in to follow this  

What's going on here?

This topic is 4861 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 a bit of code in my program that makes an alien sprite rotate in the direction of the player, wherever he moves on screen: bltfx.nRotationAngle = -((atan2((playerx - alienx),(playery - alieny)) * 5700)); I had to keep trying different values for the "* 5700" bit, till it rotated correctly. Can somebody explain what that number is? I'm using GapiDraw to rotate the sprite by the way and I believe the rotationAngle takes radians. Is 5700 converting from degrees to radians?? I'm a bit confused, as you can tell! :)

Share this post


Link to post
Share on other sites
I think you're using degrees in your program, not radians. By multplying by 5700, you're sort-of converting from radians to degrees.

To convert from radians to degrees, multiply by 180 and divide by pi. What you're doing is similar. You're multiplying by 17907 (almost 18000) and dividing by pi. (17907/pi ~~ 5700). That will give you an angle 100 times too large, but since angles are modulo 360, that is no problem.

Basically, any multiple of 180/pi ~~ 57 will work.

Share this post


Link to post
Share on other sites

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