Seagul Posted October 31, 2009 Share Posted October 31, 2009 How do I go about calculating something like so and choosing shortest distance from green dot to yellow dot. Link to comment Share on other sites More sharing options...
AndyG Posted October 31, 2009 Share Posted October 31, 2009 $distance=sqrt( (abs($x_yellow-$x_green))^2+(abs($y_yellow-$y_green))^2) ;should be old pythagoras^^ Link to comment Share on other sites More sharing options...
Seagul Posted October 31, 2009 Author Share Posted October 31, 2009 So something like this but how would I tell it to store multiple targets so I would be able to pick one under my case. like click target a. click target b. $target = _ImageSearchArea("target.gif", 1, $x1, $y1, $x2, $y2, $a1, $b1, 35) $shiptarget = _ImageSearchArea("ship.gif", 1, $x1, $y1, $x2, $y2, $sx1, $sy1, 35) $distance = Sqrt((Abs($a1 - $sx1)) ^ 2 + (Abs($b1 - $sy1)) ^ 2) Select Case $distance >= 800 sleep (15000) Case $distance >= 400 sleep(7500) Case Else call("yada") EndSelect Link to comment Share on other sites More sharing options...
AndyG Posted November 1, 2009 Share Posted November 1, 2009 So something like this but how would I tell it to store multiple targets1. while-loop, detect the positions of all possible targets 2. store these positions into an $array[$target_type][$posx;$posy] ;maybe you do not have to do so if you have only one target_type 3. in a for/to-loop, check the distance between ship and all targets (which were stored in the array) 4. if the distance between the ship and one of the targets < critical_distance then do something depends of target_type 5. wend ;goto 1 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