Create a light effect in GameMaker
Tutorial 14: Creating a Light Effect in GameMaker

You could demonstrate this effect in a separate room instead of your main playing room. If so, create a button to it on the start screen.
-
Create a new object called objLight
-
Add a Create event to this object with the following code:
/// @description Create a surface the size of the current room surf = surface_create(room_width, room_height); surface_set_target(surf); draw_clear_alpha(c_black, 0); surface_reset_target(); -
Add a Step event to this light object and paste this code.
Look out for where the player object and player laser is referenced in the code below.if (surface_exists(surf)) { surface_set_target(surf); // The following three lines set the 'dark' overlay draw_set_color(c_black); draw_set_alpha(0.8); draw_rectangle(0, 0, room_width, room_height, 0); gpu_set_blendmode(bm_subtract); draw_set_color(c_white); // Draw circles in the overlay with your different light sources // Note that I add randomization to the position and radius to mimic a flicker effect //each with statement needs to know what object you are creating the light effect around with (objPlayer) //light on the player draw_circle(x + random_range(-1, 1), y + random_range(-1, 1), 50 + random_range(-1, 1), false); with (objEnemy1)//light on the enemy draw_circle(x + random_range(-1, 1), y + random_range(-1, 1), 50 + random_range(-1, 1), false); with (objPlayerLazer) //if your player lazer has a different name change this //you will need to play with the values inside of here to show your lazer draw_rectangle(x-20,y-40,x+20,y+40,false); // Reset all of your draw stuff gpu_set_blendmode(bm_normal); draw_set_alpha(1); surface_reset_target(); } else { surf = surface_create(room_width, room_height); surface_set_target(surf); draw_clear_alpha(c_black, 0); surface_reset_target(); } -
Create a Draw End event on the light object, and copy and paste this code into it.
if (!surface_exists(surf)) { surf = surface_create(room_width, room_height); } else { if (view_current == 0) { draw_surface(surf, 0, 0); } } -
In a Room End event, paste this code:
// Clean up the surface memory manually if (surface_exists(surf)) surface_free(surf); -
Drag the light object into a room to test it.
-
If you do not want it to be part of your main game room, create a new room for it, and link to it as a bonus room for the start screen
Challenge:
Add With() conditions to the Step event if you want to see your enemy lasers

Learning GameMaker?
Code Create Play takes you through building a complete game step by step over seven days.