---------------------------------------------------------------------------- Distance Measurement on an X, Y Coordinate System --Howard Usually, (a vary vague assumption at best), a programmer needs to know the distance between two points on the x, y plane. The x,y plane is used extensivly in 2-d graphics, Hell, just about ANY graphics application uses the x, y coordinate system. One very widly used example is for a tile-based strategy game, such as Warcraft(tm), Red Alert (tm), etc. Say perhaps one needs to know if the 'target' is with-in 'range' of a weapon. Or for any reason a measure of distance is needed. There is a very simple Trigonometric formula for finding the distance between two coordinates on the x,y plane: KEY: d(A, B) -- The distance between coordinate A and coordinate B x1, y1 -- The x, y coordinates of the 'attacker' y2, y1 -- The x, y coordinates of the 'victim' sqrt -- The square root of... ^2 -- Squared or to the second power d(A, B) = Sqrt((x2 - x1)^2 + (y2 - y1)^2) If you have even the most basic knowledge of algebra (and trust me folks, it helps), you'll know the order of precedence and how it'll work. Example: Howard has a blast range of 7 units and is at coordinate 4, 9. Howard wants to blast Puffy at 8, 2, here's what will happen: d(Howard, Puffy) = sqrt((8 - 4)^2 + (2 - 9)^2) = sqrt(4^2 + (-7)^2) = sqrt(16 + 14) = sqrt(30) = 5.47 or roughly 5 units away (rounded down); He is in range and Puffy is toasted! Usually setting the variables to integers will yield a fairly accurate and more workable result. NOTE: This formula is for the workings of the game it's self. If you're looking for anything graphical, this CAN be used! *BUT*, you must adjust it for the positive and negative integers. We all know that the screen coordinate system is a little odd. Where the upper left corner (origin) is 0,0 and the lower right is x, x (depending on size, resolution, graphics mode, etc...). If your screen where on a 'regular' x, y plane and the center of the screen were 0, 0 (the origin), the upper left corner would be like -180, 180 (for example) and the lower right corner would be -180, -180. I'll leave the adjustments up to you. >:^)+) --Howard... (noemail@this.address.com) Legal crapola... The references to Warcraft(tm) and Red Alert(tm) we're made for the pourpose of example. I have nothing to do with the companies and their programmers. Don't sue me or anything. Just think of it as free advertising and whoever reads this might go out and buy the game and make 'em money. Yeah, that's it. :^) ----------------------------------------------------------------------------