Jump to content

distance between moving object and 2 targets


Seagul
 Share

Recommended Posts

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

  

So something like this but how would I tell it to store multiple targets

1. 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...