Named after the Greek philosopher Pythagoras, the Pythagorean theorem states a simple but powerful relationship between the sides of a right triangle: The square of the hypotenuse of a right triangle is equal to the sum of the squares of the remaining two sides. So, given a triangle with sides of length a, b, and c (where c is the hypotenuse), the theorem reads a Now that you know (or have finally remembered!) this simple relationship, let's see how you can use it to find the distance between two points. Imagine that there is a black ball at the point (x1, y1) and a gray ball at the point (x2, y2). What is the distance between these balls? You've probably guessed by now where I'm going with this you can use the Pythagorean theorem to find the distance between these two points. The only conceptual hurdle in this problem is to realize that there exists an imaginary right triangle whose hypotenuse is the line joining the two balls. But if you've been following along this far, that's probably not too big a hurdle. The theorem states that c With this mathematical equation you can find the distance between any two points in Flash! This useful little "recipe" will come in handy frequently. For instance, you will use it when detecting most types of collisions in your games. In ActionScript this distance formula would look like this: Distance=Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)); |

Macromedia Flash MX Game Design Demystified: The Official Guide to Creating Games with Flash -- First 1st Printing -- CD Included

ISBN: B003HP4RW2

EAN: N/A

EAN: N/A

Year: 2005

Pages: 163

Pages: 163

Authors: Jobe Makar

Similar book on Amazon

flylib.com © 2008-2017.

If you may any questions please contact us: flylib@qtcs.net

If you may any questions please contact us: flylib@qtcs.net