Targeting function
Dar Scott
dsc at swcp.com
Sun Jun 29 10:36:00 EDT 2003
On Sunday, June 29, 2003, at 05:02 AM, curry wrote:
> The input could be gun location, bullet speed, target location, target
> direction, and target speed. The output could be bullet direction or
> collision point.
Try this. If you get bogged down, let us know.
Your direction and speed is your velocity vector. In your preliminary
algebra & trig change it from angle & speed to x-speed & y-speed. Do
this for both bullet and target.
Your location, presumably, is already in cartesian coordinates and will
have components x-location and y-location. This applies to both the
gun and the target at any time.
Now that x and y are split out, they can be solved separately.
Set up your location equations based on time and velocity.
Solve the simultaneous equations where the x-location of the target and
the x-location of the bullet are equal and the same for y.
When you are done, you should have a bullet angle formula with some
trig and arithmetic.
This makes for a very smart opponent, of course.
Dar Scott
More information about the use-livecode
mailing list