Hey. I took a look at your code and fixed up a few things in repeatedly execute. You need to split up the checks for timer 1 and timer 2.
Code: ags
First if case: If the timer 1 is expired a lightning background frame is set and timer 2 is started with a random number between 0 and 80.
Second if case: If timer 2 is expired the background is changed back and timer 1 is once again started with a random number between 200 and 400. The process repeats.
You could do it with just one timer, but it's easier to see what's going on this way.
That should probably work.
if (IsTimerExpired(1) == 1) //Start lightning
{
int light=Random(1);
if (light==0)
{
SetBackgroundFrame(1);
SetTimer(2, Random(80));
}
else if (light==1)
{
SetBackgroundFrame(2);
SetTimer(2, Random(80));
}
}
if (IsTimerExpired(2) == 1) //Stop lightning
{
SetBackgroundFrame(0);
SetTimer(1, Random(200) + 200);
}
First if case: If the timer 1 is expired a lightning background frame is set and timer 2 is started with a random number between 0 and 80.
Second if case: If timer 2 is expired the background is changed back and timer 1 is once again started with a random number between 200 and 400. The process repeats.
You could do it with just one timer, but it's easier to see what's going on this way.
That should probably work.