Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ~flashlight
- -------------------------
- step event
- event_inherited();
- obj_light_lamp.x = obj_player.x;
- obj_light_lamp.y = obj_player.y;
- image_yscale = 100;
- image_xscale = 100;
- var pd = point_direction(x, y, mouse_x, mouse_y);
- var ad = angle_difference(image_angle, pd);
- image_angle -= min(abs(ad), 25) * sign(ad);
- //Custom
- var cos_value = cos(current_time*0.00012 + xstart + ystart + random_range(-0.08,0.08));
- if (cos_value > 0.972)
- {
- visible = false;
- }
- else
- {
- visible = true;
- }
- ~light torch, player light
- -------------------------
- create
- /// @description Initialize Values
- depth = obj_light_torch.depth + 1;
- //Set up Vertex
- vertex_format_begin();
- vertex_format_add_position();
- vertex_format_add_color();
- VertexFormat = vertex_format_end();
- VBuffer = vertex_create_buffer();
- //Set up Surface
- image_initial_alpha = image_alpha;
- light_radius = light_initial_radius;
- //Creating Surface
- var circle_di = light_radius*2;
- light_surf = surface_create( circle_di*1.25, circle_di*1.25);
- //Check if this one is a sprited light
- if (sprite_index != -1)
- {
- light_initial_radius = max( sprite_get_height(sprite_index) * image_yscale, sprite_get_width(sprite_index) * image_xscale);
- light_radius = light_initial_radius;
- }
- //Light Values
- Visible = true;
- --------------------------------
- draw event
- /// @description Alter
- // Inherit the parent event
- event_inherited();
- // Draw brilho
- gpu_set_blendmode(bm_add);
- //outside light
- var v_radius = 20 * random_range(0.01, 2);
- var v_alpha = 0.0025;
- draw_set_alpha(v_alpha);
- draw_circle_color(x, y, v_radius, make_color_rgb(255, 238, 53), c_white, 0);
- //inside light
- var v_radius = 20;
- var v_alpha = 0.005 + random_range(0, 0.002);
- draw_set_alpha(v_alpha);
- draw_circle_color(x, y, v_radius, make_color_rgb(255, 237, 178), c_white, 0);
- draw_set_alpha(1);
- if (irandom(4) == 1)
- uls_set_light_alpha(self, 0.6 * random_range(0.8, 0.9))
- gpu_set_blendmode(bm_normal);
- -------------------------------
- step event
- /// @description Insert description here
- // You can write your code in this editor
- obj_light_torch.x = obj_player.x;
- obj_light_torch.y = obj_player.y + 3;
- ~enemy light, parent torch, copy draw event, then parent uls_light
- ---------------------------
- step event
- # Update the light's position to match the enemy's position
- obj_enemy_light.x = obj_enemy.x;
- obj_enemy_light.y = obj_enemy.y;
- # Adjust the light's visibility and alpha value based on whether it's colliding with a wall
- image_alpha = fade_alpha;
- if (collision_circle(x, y, 32, obj_player, false, false)){
- if (fade_alpha < 1) {
- fade_alpha += 0.12;
- }
- visible = true;
- } else {
- fade_alpha -= 0.12;
- if (fade_alpha <= 0) {
- visible = false;
- fade_alpha = 0;
- }
- }
- ---------------------------
- draw event
- /// @description Alter
- // Inherit the parent event
- event_inherited();
- // Draw brilho
- gpu_set_blendmode(bm_add);
- //outside light
- var v_radius = 20 * random_range(0.01, 2);
- var v_alpha = 0.0025;
- draw_set_alpha(v_alpha);
- draw_circle_color(obj_enemy_light.x, obj_enemy_light.y, v_radius, make_color_rgb(255, 238, 53), c_white, 0);
- //inside light
- var v_radius = 20;
- var v_alpha = 0.005 + random_range(0, 0.002);
- draw_set_alpha(v_alpha);
- draw_circle_color(obj_enemy_light.x, obj_enemy_light.y, v_radius, make_color_rgb(255, 237, 178), c_white, 0);
- draw_set_alpha(1);
- if (irandom(4) == 1)
- uls_set_light_alpha(obj_enemy_light, 0.3 * random_range(0.8, 0.9))
- gpu_set_blendmode(bm_normal);
- -----------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement