Line of site beamcastin
BlitzMax Forums/BlitzMax Programming/Line of site beamcastin
| ||
Hi Guys I've been working a Rougelike game, and have recently completed some workable Line of Sight (LOS) code (see code below). What it does it to draw a semicircle in the direction the player is facing, and then uses Brasenham's Algorhithm (function Line) to draw a line between the centre point (cx,cy in function DrawMap() ) and every point that comprises the semi circle. The easiest way to get what I'm talking about it to copy and paste the code, and then get it running. In terms of the code, the important bit is the function Line(). I'm sure you guys can work out how the whole thing works :) Left + Right = adjust direction Up + Down = adjust vision distance Mouse left = create cell Mouse right = null cell Pretty straightforwards, huh? Well, if you start to adjust the vision distance you will start seeing black squares - i.e. places the line drawing function never goes through when drawing between the start point and semi-circle point. These are dead spaces that the player can't see. My question is this: can the line drawing function be tweaked to ensure that all cells are "seen" or am I barking up the wrong tree? If you can shed any light on this, I'd be extremely grateful. |
| ||
The full topic title should be "Line of sight beam casting problem", btw. |
| ||
Try www.roguelikedevelopment.org Look for recursive line of sight algorithm |