Newgrounds.com — Everything, By Everyone.

Checking login status…

USERNAME:

PASSWORD:

Logging in…

Logged in as:
.
Logging out…
Inbox My Account Log Out


Forum Topic: How do I use square root in AS2?

(107 views • 7 replies)

This topic is 1 page long.

<< < > >>
None

UberCream

Reply To Post Reply & Quote

Posted at: 7/3/08 10:23 PM

UberCream NEUTRAL LEVEL 16

Sign-Up: 11/19/05

Posts: 1,456

Someone please help me. I am making a game that uses distance formula and to calculate distance, you need square root. Does anyone know how to make a square root symbol (probably using some kind of alt-code) that would work in as2. Also, I need to know how to apply it. For example, would i say (if i want to find the square root of variable a + variable b) would it be [sq. rt. symbol] * (a+b) or would i have to do something else?

-Collabs I'm In: 1 F., N.H.T.H.C., L.C.R., F.H., O.B.M.O. -

BBS Signature

None

Fion

Reply To Post Reply & Quote

Posted at: 7/3/08 10:28 PM

Fion LIGHT LEVEL 28

Sign-Up: 08/21/05

Posts: 2,086

If you want the square root of a + b simply use this:

Math.sqrt(a+b)


None

UberCream

Reply To Post Reply & Quote

Posted at: 7/3/08 10:31 PM

UberCream NEUTRAL LEVEL 16

Sign-Up: 11/19/05

Posts: 1,456

At 7/3/08 10:28 PM, Fion wrote: If you want the square root of a + b simply use this:

Math.sqrt(a+b)

Wow, thanks! I tested it out and it worked!

-Collabs I'm In: 1 F., N.H.T.H.C., L.C.R., F.H., O.B.M.O. -

BBS Signature

None

UberCream

Reply To Post Reply & Quote

Posted at: 7/3/08 11:12 PM

UberCream NEUTRAL LEVEL 16

Sign-Up: 11/19/05

Posts: 1,456

Here is the test! You can drag around the red circle!

-Collabs I'm In: 1 F., N.H.T.H.C., L.C.R., F.H., O.B.M.O. -

BBS Signature

None

CaptainPoncho

Reply To Post Reply & Quote

Posted at: 7/3/08 11:41 PM

CaptainPoncho EVIL LEVEL 08

Sign-Up: 11/29/03

Posts: 524

At 7/3/08 11:12 PM, UberCream wrote: Here is the test! You can drag around the red circle!

Why did you have to use square root to do that?


None

Coolio-Niato

Reply To Post Reply & Quote

Posted at: 7/3/08 11:52 PM

Coolio-Niato LIGHT LEVEL 23

Sign-Up: 06/30/05

Posts: 1,651

At 7/3/08 11:41 PM, CaptainPoncho wrote:
At 7/3/08 11:12 PM, UberCream wrote: Here is the test! You can drag around the red circle!
Why did you have to use square root to do that?

x cord 2 - x cord 1

ycord 2 - y cord 1

xdiff + ydiff sqrted is distance. simple pythagus theorum.

=)

BBS Signature

None

CaptainPoncho

Reply To Post Reply & Quote

Posted at: 7/3/08 11:59 PM

CaptainPoncho EVIL LEVEL 08

Sign-Up: 11/29/03

Posts: 524

At 7/3/08 11:52 PM, Coolio-Niato wrote:
At 7/3/08 11:41 PM, CaptainPoncho wrote:
At 7/3/08 11:12 PM, UberCream wrote: Here is the test! You can drag around the red circle!
Why did you have to use square root to do that?
x cord 2 - x cord 1

ycord 2 - y cord 1

xdiff + ydiff sqrted is distance. simple pythagus theorum.

Oh, for the distance. I thought he was trying to use sqrt to move the dot around.


None

Edvin

Reply To Post Reply & Quote

Posted at: 7/4/08 05:57 AM

Edvin DARK LEVEL 12

Sign-Up: 02/03/04

Posts: 1,809

At 7/3/08 11:52 PM, Coolio-Niato wrote: xdiff + ydiff sqrted is distance. simple pythagus theorum.

Nein, xdiff^2 + ydiff^2 sqrted is distance.


All times are Eastern Daylight Time (GMT -4) | Current Time: 04:47 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!