Jump to content
  • Advertisement
Sign in to follow this  
whaleyboy

What's going on here?

This topic is 5227 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!