Shortest distance to a rawdraw line? (SOLVED)

Started by LeChuck, Fri 14/09/2007 12:15:22

Previous topic - Next topic

LeChuck

I'm trying to make my character automatically walk to the closest point on a rawdraw line. How do detect which coordinates on a rawdraw line that are the closest to a character?

Also, is there a way of changing the colour of the rawdraw line, or making it transparent?

Edit: does this belong in the technical forum?

Khris

The first (main) part is a rather mathematical than technical question.

To address the second question:
As soon as a rawdraw line is drawn it becomes a part of the background, indistinguishable from the imported background images (at least to AGS).
You can change the color by drawing another line right onto it.

If you want the line to be movable and/or transparent, use a graphic overlay instead.

pseudo code:
RawSaveScreen();
clear screen with color 0
draw line
grab DynamicSprite
RawRestoreScreen();
display overlay using DynamicSprite.Graphic

The player won't notice the black screen because the screen isn't updated visibly in between saving and restoring the screen.

Getting back to your first question:
The best solution depends on how accurate it has to be and on whether the closest point has to be on the rawdraw line (as opposed to being on the straight line defined by the two rawdraw end points).

LeChuck

Thanks for clearing up the RawDraw issue for me. I've found a much simpler solution to my problem that didn't involve any math, although I'd use the Distance function in this thread if I decided I had no other choice.

SMF spam blocked by CleanTalk