I have a procedural 2d game which extends in all directions, on the surface similar to Terraria. When a player moves their camera close to the edge of the currently loaded terrain, I trigger an expand event, which loads new chunks of terrain. Each chunk is an N×N section of tiles. When I do this I get a stutter of about 1 second due to the cost of procedurally generating the new tile set.
How can I avoid that delay?
Currently, all new chunks are loaded in the same iteration of the update loop (bad I know). My current idea is to create a queue to store the chunks and only render 1 chunk per game update.