I'm making a game with world generation and I want to display the generation progress on screen. Even with the for loop inside of an async function it stops all other code outside of the function to run the loop.
I've tried a forEach loop which had the same issue and had worse performance.
async function genWorld(){
setupWorld();
}
async function setupWorld(){
let size = worldSize.width * worldSize.height;
let up = size/100;
let check = 0;
for(i = 0; i < worldSize.width; i++){
for(z = 0; z < worldSize.height; z++){
check++;
if(check == up){
console.log("test");
check = 0;
worldGenProgress.full++;
}
}
}
}
I expect the progress bar to graphically update inline with the for loops instead of jumping to 100% once they finish.