I would just use the timer trick Blaze suggested
Here is a little tutorial:
- Create a new object called: "obj_daynight"
- Put this piece of code in the create event:
Code:
global.intensity = 0;
fase = 0;
alarm[0]=10
- Put this piece of code in the alarm 0 event:
Code:
if global.intensity == 1{
fase = 1;
}
if global.intensity == 0{
fase = 0;
}
if fase == 0{
global.intensity += 0.01;
}
if fase == 1{
global.intensity -= 0.01;
}
alarm[0] = 10;
- Use the global.intensity value in your draw_ext call like this:
Code:
draw_sprite_ext(sprite_index, 0, x - 16, y + 20, 1, 1, 0, c_black, global.intensity);
This will give you a really quick day/time cycle, but you get the idea, just play around with the variables to change it to your likings. The shadows will increase and decrease in density over time now.
The easiest thing you can do now to get a full day/night cycle to work, is by drawing a completely black square filling the whole screen, the alpha value of the square should be equal to: 1-global.intensity
The code will look somewhat like this: (don't forget to give the object that draws this rectangle will have a really low depth, like -10000, this way it will draw above everything else)
Code:
draw_set_alpha(1-global.intensity);
draw_rectangle(0,0,room_width,room_height,false);
draw_set_alpha(1);
If the rectangle is drawn white instead of black, use this code:
Code:
draw_set_alpha(1-global.intensity);
draw_set_colour(c_black);
draw_rectangle(0,0,room_width,room_height,false);
draw_set_colour(c_white);
draw_set_alpha(1);
Well, I can't really make this tutorial more detailed than it already is, so good luck with this!