Thursday, May 21, 2009

(broken) los, (sorta) working combat, and other misc features

I've added a stab at some basic line of sight using a couple ideas. My first thought was to use the midpoint circle algorithm to generate the list of end points which I would then run traces along using Bresenham's line algorithm to generate the points. That of course generated a very pretty circle without nearly enough traces to cover the actual interior area.

Round two, generate a circle of end points using ol' fashioned cosine/sine, stepping the angle by an educated guess (Pi/(Radius^2)) and then trace to those end points using Bresenham's again. This generated slightly better results (near perfect @ 4 > Radius <= 8 or so), but anything other than that small set of magic numbers causes holes due to Bresenham's skipping. Next step is to just breakdown and write a trace that correctly touches all cells, and will give me the flexibility to handle various 'edge' cases depending on the angle of the trace (stuff like illuminating the walls of a corridor). For now I'm living with half-working solution #2, telling myself I have much bigger fish to fry...


At any rate, adding even broken LOS makes a huge difference in the feel of the game, and adding the various bits starts to glue everything together. More stuff keeps catching me unexpectedly, such as the seemingly simple combat text. When to capitalize, when to not, arbitrary formatting of strings based on various attack attributes, etc all add up to a bit more than you'd expect.

at any rate, basic combat is in with some bells and whistles. Goblins all get daggers - which they drop on death of course, although you can't pick them up, rats get their claws, and you the daring 'DEBUG' get your amazing hand of god which annihilates anything if it manages to hit.

No comments:

Post a Comment