Light Maze


Released: June 1, 2015
Tags: GML, Shaders, Horror, Game Maker 8

I got really interested in exploring 2D dynamic lights at some point because I had seen some really cool effects being done with them in GameMaker: Studio. GM8 unfortunately didn't support the shaders which were required to do these effects, so instead I tried to write some light emission effects in 2D. After I wrote the engine, I made a small demo game where the player searches a pitch black maze filled with monsters for the exit. The player is always carrying a light emitting torch, and the player can place up to 5 torches on the floor so that they can keep track of where the monsters are in the maze. I also tried playing with the light engine some more (and the horror AI) by making a game where you have a UV light and you use it for finding clues, but I didn't get very far beyond just a prototype level, as well as a top down shooter that used the light engine for muzzle effects (among other things).

The way that the light system works is by requiring me to define explicitly the vertices of the shapes which I wish to block light/project shadows. Then, when a light is placed in the game, it will check which objects it's close to, and project lines from the center of the light source to in the direction of each vertex of the shape until the maximum distance that the light emits. The generated penumbra object is turned into a triangle strip for maximum efficiency, and in the end a penumbra sprite is placed at the edges to add some smoothness between the light and dark. The final penumbra is then additive blended into the rest of the surface where all the other lights and penumbras are placed. Since I am using surfaces to draw the lights to, the code for the light logic is done in the update function so that it is only updated when a light's property changes. The lights can have different shapes, colors, and sizes.


Return to projects