Novel. When the player draws the line: determine the squares at the start and end, and get their ship-layout coordinates; highlight up to N squares along that line, in order of distance from the start; where N is the max range of the weapon.Estel wrote:Lets just have beam ranges in units of "box borders"
* In ship-layout space, determining whether a line from square (2,4) to (8,7) passes through the border of square (4,5), depends on the perpendicular distance from that square (effectively its center) to the line, and [because they're pointy] the angle of the line (distance >0.5 is outside the square when angle is 90 degrees, versus 0.707 at 45 degrees).
The same trig is involved. Varying damage per-square and varying square-count per angle are comparable in that regard.Estel wrote:This way, we drop all resolution-related problems (box is box, no matter of resolution on-screen), and don't need to get into advanced math for calculating simple beam, that just does 1 damage per room.
Coping with resolution was only ever a matter of multiplication by a scale, but shifting to ship-layout point space early is simpler. An API that could test the intersection of unrendered rectangles in an idealized 35px-square space with an unrendered line, could also test a line's distance to an unrendered point in ship-layout space. The programmer would have to manually account for 'corners' on the points, but it's probably the same math the API would've done had they been 35x bigger, minus all the imaginary rectangles.
And handling one damage value in a blast is a little simpler to code than handling several.