Sign in with
Sign up | Sign in
Your question

Help needed with basic pathing

Last response: in Video Games
Share
Anonymous
July 16, 2005 7:32:57 PM

Archived from groups: rec.games.roguelike.development (More info?)

need help... code is ok, or just math and pseudo code (even better)

I need a way to figure out exactly which squares (on a grid based map)
are crossed by a missle type object. It's easy to eyeball, but I can't
seem to wrap my head around the math to reliably draw a line from
(x1,y1) to (x2,y2).

I can handle straight lines and true diagonal lines no problem, but in a
case where the "line" goes "staggered"... I just cant see it. Not enough
sleep or caffeine probably.

................
................
...@xx..........
......xx........
........xx......
..........K.....
................


Any help is appreciated.

Those of you that play ADOM, that's the basic look I'm going for... when
you target a monster and it draws a line from you (x1,y1) to it (x2,y2).

Just need help with the math/algorithm, once i have that I can write the
code.

Thanks,
S.

More about : needed basic pathing

Anonymous
July 17, 2005 12:03:05 AM

Archived from groups: rec.games.roguelike.development (More info?)

airolson wrote:
>> Just need help with the math/algorithm, once i have that I can write
>> the code.
>
>
> What you need is Bresenham's Line Algorithm:
>
> http://www.gamedev.net/reference/articles/article767.as...
>
> Google for more info. :) 
>
> -Aaron

Yes!! That looks perfect!

Thanks,
S.
Anonymous
July 18, 2005 12:50:45 PM

Archived from groups: rec.games.roguelike.development (More info?)

At Sat, 16 Jul 2005 15:32:57 -0400,
Heroic Adventure wrote:

> need help... code is ok, or just math and pseudo code (even better)

http://roguebasin.t-o-m-e.net/index.php/Breshenham%27s_...

--
Radomir `The Sheep' Dopieralski @**@_
(`') 3 Grrr!
. . . ..v.vVvVVvVvv.v.. .
!