V
Vanthex
Guest
Hi
This is my game lol:
As you can see how the lighting works. I want to make it so that everytime i create or destroy a block the lighting is updated. As you can see, the block the player is standing on is still dark, which is wrong because light from above should make it bright.
Here is my code:
scr_alpha is a script that returns a value of how dark a block should be:
Then in the object called obj_tile, in the create event the value is set to a variable called alpha:
In the draw event of the object, i then draw the tile with the correct brightness:
My questions is how do I loop these procedures? OR either how do I make it so that it only updates the lighting when a block is created or destroyed? ( I used left mouse button released and right mouse button released)
This is my game lol:
As you can see how the lighting works. I want to make it so that everytime i create or destroy a block the lighting is updated. As you can see, the block the player is standing on is still dark, which is wrong because light from above should make it bright.
Here is my code:
scr_alpha is a script that returns a value of how dark a block 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;
Code:
alpha = scr_alpha();
Code:
//Draw self
draw_self();
//Draw darkness
draw_sprite_ext(sprite_index, image_index, x, y, 1, 1, 0, c_black, alpha);