Phase Based Procedural 2D Level Generation


Academic Project


Details

  • Unity Engine
  • Academic Project
  • January 2023 - March 2023

Project Details

  • Designed a procedural level generator for 2D top-down shooter mechanics, ensuring spatial variety and replayability with randomly generated room layouts and connections.
  • Improved room and corridor generation by adding branching paths, diverse shapes, and size variations to create visually interesting and intricate levels.
  • Created a modular system for unique modes of generation, resulting in varied development phase layouts leading up to the boss arena.
  • Curated a procedural system to spawn enemies of increasing difficulty and pickups with distinct gameplay effects depending on the phase and generation mode, ensuring variety and strategic depth.
  • Developed a multi-phase boss capable of firing wall-destroying shots, with similar enemies, delivering intense and balanced encounters.
  • Conducted playtesting to refine gameplay flow, identifying and addressing bottlenecks to improve player experience.

Implementation in Review


Procedural Top Down Shooter: Modes and Phase Based Generation Design


  The algorithm starts out by dividing the level into diagonal slices, where each phase selects modes from its possible pools. In addition, it selects corners to spawn the starting room and the boss room. The starting room gets spawned first to give the generation a starting point at the room's corner facing the center.

  Next, the algorithm continues generating towards the opposite corner, with the logic for each tile that it places being changed depending on the phase of the current tile. These modes of generation provide unique spatial challenges to the player to keep gameplay varied, but still intentionally designed. The phases for the accompanying picture are as follows:

  • Setup: Setup Mode - Characterized by medium length hallways, leading the player easily to the next phases.
  • Development 1: Maze Mode - Characterized by short and often branching hallways, allowing for the next phases to have more tiles entering them.
  • Development 2: Diamond Mode - Characterized by small rooms, where the corners are cut.
  • Development 3: Big Room Mode - Characterized by large rooms, where elite-type enemies have the space to battle players within.

  After this step, the Boss Room gets spawned in the corner opposite to the setup phase. The arena is set up such that the player has enough space to engage the boss as well as ensuring that the path to the boss is traversable. In addition to spawning the space, this step also includes spawning powerups in a hall before the boss room in order to help afford what the room is.

  The algorithm does another final sweep over the generated level at this step, ensuring that the following conditions are met: 1) The player is able to navigate to and get inside the boss room, 2) Enough rooms spawn in the level in order for players to explore and engage enemies within them, and 3) Enough tiles spawn in the level in order to meet the engagement type of exploration. If one or more of these conditions are not met, the level regenerates.

  In addition, power ups are added to the level in this pass to reward the player's exploration of some of the longer paths (seen by the arrows). In addition, a speed powerup is placed at the start of the first development phase to introduce powerups to the player and acts a hook as well.

  Once all of the validation checks pass, the level spawns walls and enemies at appropriate tiles in the various phases. Each mode of generation has different pools of enemies that it’s able to spawn and weighting for how often that enemy spawns. For instance, sniper enemies are highly likely to spawn in the third development phase for modes that have long corridors. This is done since snipers are able to pierce through and destroy walls with their shots, opening up new paths for the player to take. It also helps introduce the wall destruction mechanic the boss and final powerup uses.

  The accompanying gif is a visualization of how the dungeon generates. Some of the generations fail due to the factors specified above, but others succeed, shown by the spawning of the boss room and dungeon walls. In all, there are 8 different modes that the dungeon may generate, which vary the most in the development 2 and development 3 phases. This is done to ensure a large level span from the start as well as to keep the beginning phases more friendly for the lower power of enemies found there.


Project Outcome

The algorithm successfully generates varied dungeon layouts with distinct phases, providing players with unique spatial challenges and intentional gameplay design. Each phase contributes to a cohesive progression, from guided exploration in the Setup Mode to intense elite combat in Big Room Mode. Validation checks ensure player navigability, engaging exploration, and balanced enemy encounters, creating replayable levels that adapt dynamically to different generation modes. Through this project, I learned how to design systems that balance procedural variation with intentional design, ensuring proper enagement for players.

}