ZebrasInBlankets Posted May 9, 2005 Share Posted May 9, 2005 I am trying to find out how to get from one point to the next using autoit. The purpose is waypoints for a game I am working on. I know my starting location and my destination, but I do not know how to get there. The points are plotted on a standard 4 quadrant graph.Here is what I am talking about.The Red Dot is my starting location and it is at (3,-3)The Blue Dot is my destination at (5,-1)Look at the graph as a piece of land, and you standing on the red dot. You know you are at (3,-3) and that you need to get to (5,-1). However, you do not know which direction to move. How could I find out which direction to face and then move to the location?I am sure there is a way to do this mathmatically, but it has been a while since I was in High School math and didn't like it much anyway. Any help is greatly appreciated!Thanks Link to comment Share on other sites More sharing options...
CyberSlug Posted May 10, 2005 Share Posted May 10, 2005 (edited) I'm rusty, but: (3,-3) and (5,-1) change in X is -2 change in Y is 2 Slope is rise over run (delta Y / delta X) == 2/-2 == -1 for every x coordinate you increment by 1, you decrement y coord by 1. EDIT: (So I guess that's north-east) Edited May 10, 2005 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Ejoc Posted May 10, 2005 Share Posted May 10, 2005 (edited) end x - start x, end y - start y 5-3,-1--3 or 2,2 that's your right triangle to calculate the direction from. Bah, too slow of a typer Edited May 10, 2005 by Ejoc Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
ZebrasInBlankets Posted May 10, 2005 Author Share Posted May 10, 2005 I will need to spin the character in the right direction in order to run the right way to the target coordinates. Without being able to directly edit the current coordinates, other then hitting the run forward and turn keys. Would it even be possible? Link to comment Share on other sites More sharing options...
mother9987 Posted May 10, 2005 Share Posted May 10, 2005 I will need to spin the character in the right direction in order to run the right way to the target coordinates. Without being able to directly edit the current coordinates, other then hitting the run forward and turn keys. Would it even be possible?<{POST_SNAPBACK}>Do you have a way to find your current orientation? It's a bit of simple trig to find your desired direction, but you need to know your current one for it to be useful. Link to comment Share on other sites More sharing options...
Ejoc Posted May 10, 2005 Share Posted May 10, 2005 I'd seriously suggest going to the book store and either buying or read on of the many game programming books. They explain how to do all of this. Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
buzz44 Posted May 10, 2005 Share Posted May 10, 2005 (edited) Look at the graph as a piece of land, and you standing on the red dot. You know you are at (3,-3) and that you need to get to (5,-1). However, you do not know which direction to move. How could I find out which direction to face and then move to the location?I think the below syntax is correct for you to work out if its N, W, E, S, NE, SE, SW or NW.Corret me if I'm wrong please.expandcollapse popupX = (X2 - X1) Y = (Y2 - Y1) Gradient(M) = Y / X A = X ;Adjacent O = Y ;Opposite H = Sqrt (X^2 + Y^2) ;Hypotenuse sin = O/H cos = A/H tan = O/A If M = 0 Then If X > 0 Then East ElseIf X < 0 Then West EndIf Else If M = "-1.#INF" Then South ElseIf M = "1.#INF" Then North EndIf EndIf If sin > 0 AND cos > 0 AND tan > 0 Then North East ElseIf sin > 0 AND cos < 0 AND tan < 0 Then North West ElseIf tan > 0 AND cos < 0 AND sin < 0 Then South West ElseIf cos > 0 AND tan < 0 AND sin < 0 Then South East EndIf Edited May 11, 2005 by Burrup qq Link to comment Share on other sites More sharing options...
Fur Posted May 10, 2005 Share Posted May 10, 2005 you're going to have a heck of a time if you don't like math! i would recommend looking into the A* algorithm, but sounds like that would be over your head.. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now