Procedurally Generated Dungeon

A top-down 2D dungeon crawler built in Unity, focusing on procedural generation, shop mechanics, and modular programming. The project aimed to improve my gameplay programming skills by implementing data structures, design patterns, and good coding practices.

  • Procedural Generation System

    The dungeon generates rooms, corridors, floors, and then populates them with collectibles (coins, keys, doors) and enemies. Rooms are positioned randomly within bounds, with collision checks to prevent overlaps. Corridors connect room centres horizontally or vertically, maintaining uniform width. Keys always generate in the last room, while the player spawns in the first. Each playthrough produces a different layout, ensuring replayability.

  • Coding Practices & Design Patterns

    I adopted industry-standard programming practices, including:

    • Singleton pattern for managing shared data across scenes.
    • Lists for storing rooms, corridors, and objects to allow batch operations.
    • Modular functions for expandability and maintainability.
    • Proper naming conventions, comments, and version control.

    These practices made the code reusable and expandable, setting up a strong foundation for future projects.

  • Gameplay Loop & Shop System

    The gameplay loop challenges the player to collect coins, find a key, and unlock the door to progress. Each new level increases dungeon difficulty. Coins can be spent in a shop to buy power-ups, introducing progression and strategy. A singleton tracks coins, shop items, and variables across scenes, ensuring consistency.

  • Challenges & Solutions

    Corridor Generation: Initially corridors failed to connect rooms due to incorrect centre calculations and list-clearing errors. Debugging fixed the issue by recalculating room centres and resetting lists for each iteration.

    Tilemap Wall Gaps: Corners sometimes misaligned when rooms and corridors overlapped, leaving gaps. This remained partially unsolved but identified as an area for future improvement.

    Version Control Issues: Unity’s version control failed to transfer scenes correctly between devices. The solution was to wipe and re-create the repository.