Discussions

SmileBASIC Community

MartineX22D64

08/24/2016 8:15 AM ·Spoilers

Open Closed

sprite direction with the circle pad

This is the math to find the direction a sprite goes depending on the angle. xx=cos(angle*pi()/180) yy=sin(angle*pi()/180) What I need to know is how to find the angle depending on the direction(the complete opposite). I'v tried flipping the formula around with no luck. Can anybody help?

Advertisement

Comment

This post has no comments.

  • You can get angle with the following formula. angle=ATAN(yy,xx)

    Yeahs1
  • In my previous post, the angle is given in radian. If you want to get angle in degree, you can transform it with the following methods. degree=180*radian/PI() or degree=DEG(radian)

    Yeahs2
  • Thanks.

    Yeahs0
    Played
  • As Hanzo said, you can find the angle (in degrees) with DEG(ATAN(y,x)). However, be mindful that values range from -180 to 180 degrees. In case you want the values to range from 0 to 360 degrees, you can easily set a conditional like this... STICK OUT X,Y ANG=DEG(ATAN(Y,X)) IF ANG<0 THEN INC ANG,360 ENDIF

    Yeahs1
    Played

Add a Comment

You must sign in to post a comment.

Sign in using a Nintendo Network ID to connect to users around the world by writing posts and comments and by giving Yeahs to other people's posts. You can create a Nintendo Network ID using your Wii U console or your system in the Nintendo 3DS family.

Use of Miiverse Details about Miiverse

Report Violation to Miiverse Administrators

You are about to report a post with content which violates the Miiverse Code of Conduct. This report will be sent to Nintendo's Miiverse administrators and not to the creator of the post.

Violation Type:

Post ID: 3DB-NBL7-EJ9-9E2D-H6K-WTTW

Report Violation to Miiverse Administrators

You cannot report posts made automatically by a software title.

Edit Post

Select an action: