**The Face-off**I'm getting close to finished with the flood-fill implementation, including (I hope) those pesky stairs. The nice thing about solving the stairs problem is that if I want non-orthogonal wall planes in a future version of the engine, I will be well on my way. In fact, I realized many of the problems I have to solve stem from wanting to use a tile-based scene editor. I could also enter the wall faces some other way.

Once I move away from Temple of Idosra, I want to revisit the roguelike (or is it roguelike-like?

) concept. Tile-based levels seem easier to generate.

But--on the topic of faces, there's still one last problem to solve... the final boss: Drawing shadows on the walls. Wall faces act like a canvas. Once I get the canvas, I need to know where the shadows lie.

This is a tricky problem to solve. It's been solved in 2D a few times. Here's a good example:

http://ncase.me/sight-and-light/I have yet to find an example of a solution to the 2.5D variation of the problem that didn't use a 3D engine... probably because it's much easier to just use a 3D engine. But I think I can get better performance using a 2D engine and adding just the features I need to get 2.5D, rather than using a 3D engine and "wasting the other .5D", if that makes any sense

Since most of the scene data is in 2D, my plan is to compute the shadow locations in 2D in step one, then the height/z-location of the shadows in step two. Step one is more complex, since this is the step where I need my replacement for Box2D raytracing.

To begin, let's figure out where the shadows intersect the wall face planes. Intersections with planes orthogonal to the XY plane (the floor) seem easier to handle. I've yet to work out intersections with the floor itself, but one thing at a time.

These are the possible scenarios in which a wall will cast a shadow on another.

It makes more sense if you saw this demo and the

corresponding code:

One line segment is a ray projected from the light source and through one edge of a wall face (for this example, let's use vertex A). The other line segment is the wall face itself. t is the location along line AB. If t lies between 0 and 1, then the ray intersects the wall segment.

Just looking at this I realized I left off the case where the wall casting the shadow is smaller than the one being casted upon. That should be t

_{LA} is in [0,1]

**and** t

_{LB} is in [0,1], which is a variation of Case 3.

The annoying thing about working on this will be debugging both the code and the math, since I wouldn't be surprised if I left off a case or two. At least I set up the "edmap" utility. An appreciable fraction of my development time has gone into debugging tools (like the map viewer, image viewer, node viewer, etc.)... but I couldn't imagine doing this without those tools. When something goes wrong, there are just too many places to need to look.