Help needed with basic pathing

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.
3 answers Last reply
More about help needed basic pathing
  1. Archived from groups: rec.games.roguelike.development (More info?)

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

    Google for more info. :)

    -Aaron
  2. 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.asp
    >
    > Google for more info. :)
    >
    > -Aaron

    Yes!! That looks perfect!

    Thanks,
    S.
  3. 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_Line_Algorithm

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

Read More

Development Video Games