• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Lighting system help

V

Vanthex

Guest
Hi guys,
Basically what I'm asking is that I have a lighting system, when an instance is created or destroyed, the lighting will be updated. So I tried to put the code into a step event and it was way to laggy. I also couldn't figure out how to tell gamemaker to reexecute the code under the left mouse button released and right mouse button released events.
Here are the codes
I have a script called scr_alpha that determines how dark the instance should be:
Code:
    var a = 0;

    for (var i = 1; i <= 4; i++) {
    if (place_meeting(x, y - (sprite_height * i), obj_tile)) {
        a += 1;
    }
    }

    if (a > 0) {
    a = (a * 25) / 100;
    }

    return a;
Then the object called obj_tile has a create event which has the code:
Code:
  alpha = scr_alpha();
Then it also has a draw event which draws the object:
Code:
    //Draw self
    draw_self();

   //Draw darkness
   draw_sprite_ext(sprite_index, image_index, x, y, 1, 1, 0, c_black, alpha);
The code is being placed in 3 different places, how do I still execute them under one event, for example when left mouse button is released, an instance is destroyed, all the instances around it need a lighting update.

here is the code for the event:
Code:
    if ((obj_selection.x == mouse_x - (mouse_x mod 32)) && (obj_selection.y == mouse_y -                    (mouse_y mod 32)) && global.Reach = 1) {
    instance_destroy()
    ds_grid_set(global.worldgrid,obj_selection.x/32,obj_selection.y/32,0)
    }
basically it checks if the mouse is hovering an instance that is within reach and if it is it destroys it
 
B

Becon

Guest
if !object_exists(your_obj_that_gets_destroyed)
{
with (obj_Ones_left) Update your code
}
Let me know if that helps.
 
Top