2D Raycasting and Lighting

Hello, I am wondering how I could implement 2D ray-casting in a Slick2D game, for lighting purposes. I realize that Slick2D is somewhat dead but that is irrelevant to ray-casting, as far as I know.

The “map” would consist of either rectangles or line segments.

I’ve read the article at http://www.redblobgames.com/articles/visibility/ but I can’t seem to figure out how this is implemented in Java.

My best guess is to have a Ray class and a Line class and determine where intersections lie, and then create triangles from those points. Also, on a slightly irrelevant note, I have not learned how to create radial gradients in Slick2D, any help there would be appreciated too. I’m also wondering if efficiency would be an issue in a situation where there are a large number of lines. I hope my question makes sense. :-\

One other question: how would I combine the lights from multiple sources? I’m thinking additive blending or perhaps transparency would be the solution.

Any help would be appreciated!

Once I’ve implemented the following method:

Take the octant aligned to the positive x-axis and the y-axis with (y < x). Scan it left to right. Keep track of shadowed intervals. Merge overlapping shadow intervals.

Done.

Now use affine transforms to map the other 7 octants on the first one, and you can do a full field of view calculation.

You can find my code here:

http://sourceforge.net/p/rlgamekit/code/HEAD/tree/RoguelikeGameKit/trunk/rlgamekit/fieldofview/

Ready to use, but it assumes a grid-based map. The algorithm is fairly easy to extend for other map types, though.