Escaping a SetInterval?

Im tyring to have something happen in waves.

I want to dynamicly stop and restart a SetInterval loop i’m in. Because of the variable changing it would make more sense logicly if I looped things outside the setinterval

(rather than within the interval itself)

is this a bad idea / how would I accomplish this?

I am revisiting this again. I can’t figure out why this locks the system up… All that I could imagine it being was that the while(!gameover) outer loop was executing too fast,

so i tried to wrap that in an interval to check … but it still crashes

new attempt:


start_level = 1;
OUTER_ID = setInterval(OuterGame,500);

function OuterGame(){
    
    game_over =0;
    //initiate ball droppping
    while(game_over==0){
    if(start_level==1){
        start_level = 0;
        ID = setInterval(DropBall, my_interval);
    }
}
}