Play with light and dark using ray casting and visibility polygons

Article by Richard Davey. Posted on 3rd Feb 2015.   @phaser_

"The concept is simple: starting from the “eye” of the player, we cast a series of rays and for each ray we find the first segment the ray hits. We can say there is light until the ray travels free, and dark once the ray is stopped by a segment."


"My survival horror prototype used a poor ray casting method since it only fired a series of rays here and there – every n degrees – checking for collisions with a bitmap object."

Read the full tutorial