Skip to content

unsettledgames/LevelGenerator

Repository files navigation

LevelGenerator

The LevelGenerator is a C# program that generates levels (in bitmap format) composed by rectangular rooms connected by corridors. It is perfect for 2D top-down games, but it can also be used to build levels for sidescroller games.

How does it work?

  • The program starts by generating a single room.
  • For each side of the room, a corridor will be added (depending on the corridorProbability and if there is enough space), along with a room at its end.
  • The process basically continues until the number of generated rooms equals nRooms
  • To give it a little bit more of randomness, the room to which the corridors are added, can change depending on a parameter
  • Parameters

    At the moment, it is not possible to send any input to the application; for debug purposes I only made it possible to change the generation parameters via code (which is much faster than having to insert the correct parameters all the times). However, input will be surely implemented. We can probably let the user decide to use fixed params or custom ones, so that we can still debug fastly.

    Here are the generation parameters:

    • minRoomWidth: minimum width of each room
    • maxRoomWidth: maximum width of each room
    • minRoomHeight: minimum height of each room
    • maxRoomHeigh: maximum height of each room
    • minCorridorWidth: minimum width of each corridor
    • maxCorridorWidth: maximum width of each corridor
    • minCorridorHeight: minimum height of each corridor
    • maxCorridorHeight: maximum height of each corridor
    • maxCorridorsPerSide: maximum number of corridors attached to a single side of the room
    • corridorProbability: probability (from 0 to 100) that a corridor is attached to a side of a room
    • nRooms: total number of rooms to generate
    • backgroundColor: the background color in the resulting bitmap
    • foregroundColor: the foreground color in the resulting bitmap
    • roomChangeProbability: probability (from 0 to 100) that the program changes the room to attach corridors to

    To do:

    • Add perlin noise to the borders of the rooms
    • Existing bitmap opening (requires to build some kind of format to store data about rooms and corridors)
    • Add a GUI (at least to show a preview of the bitmap, but it can be also used to input parameters)
    • Have corridors that are not just a straight line from a room to another
    • Possibility to add a level starting from a room of an existing level
    • Cropping bitmap in case of excessive space

    Notes

    Distributed under the GPL3 license.

About

Procedural level generator written in C#

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages