I'm developing a game, and I'm having some trouble. I would like to have a funtion wait(frames)
that would make a function wait some frames before continuing.
I have a main loop like this:
setInterval(function() {
refreshMap();
}, 35 );
And a function like that:
function sayHello(){
console.log("hello 1");
wait(5);
console.log("hello 2");
}
The wait(5)
function would make the game refresh 5 times before executing console.log("hello 2");
. Is it possible to do without freezing the entire game like setTimeout()
?