Endless Maps in Agent Aliens

By: sleipnir


Our colorful levels change each time you play!


This time I’ll be taking you through our level generation. Normally, all of this gets done within a single frame in the loading screen but I was challenged to slow it down step by step so it would be observable. Fortunately, Unity’s Coroutines make this relatively easy since it enables us to add delays between method calls.
 


A level made up of mostly horizontal rooms.


First, we lay the rooms out. A room is generated one after the other with random sizes. Doors are made and aligned to the previous room. When a new room intersects an old one, a correction is made by backtracking a few rooms back. Of course, just doing random sizes won’t produce pretty results. I’ve added a lot of custom conditions to control the room placements. It evolved over time from observing hundreds of results.

Next is tile generation. Our atlases are standardized so they can be swapped easily. Earlier versions of the game combined laying out the rooms and tiles. This proved to be very inefficient since it was creating hundreds of game objects that were often destroyed by backtracking. Separating these steps helped cut our loading times immensely.
 


The levels can also go vertically.


The backgrounds were tricky to make. Within the rooms they’re essentially masked, infinitely scrolling, tiled, and parallaxed. Developing it involved looking into a lot of shader code and patching them together. I started from multiple sprites, then even manually moving them. The final solution involves a single quad with an animated texture that’s synced to our camera.

In each room we also have a bunch of destructibles like crates, lights and other doodads. All of them are made in a similar fashion using noise functions. Noise is favorable over just any random number function since it makes the objects appear more often in clusters that sort of make sense and are more visually appealing.

Traps are the latest addition to the endless levels. They appear more often in the higher levels. Each kind of trap has a variant that can appear on a random side of any room.

That's all for now, thanks for reading.
Be sure to stay tuned for more updates on Agent Aliens!
 
 


Ready for a challenge?



DISCUSSIONS