GithubHelp home page GithubHelp logo

premvarijakzhan / 2d-dungeon-generator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from benpyton/2d-dungeon-generator

0.0 0.0 0.0 1.71 MB

2D Dungeon Generator C++ Library with Unity Integration Plugin and Sample

License: MIT License

C 1.36% C++ 83.47% C# 15.17%

2d-dungeon-generator's Introduction

2D Dungeon Generator

Author : PELLETIER Benoît

Description :

2D Dungeon Generator is a C++ library I made for a school project.
The generation use BSP (Binary Space Partitionning) algorithm. The placement of enemies and chests are totally random, and key placement use bidirectional BFS (Breadth First Search) path finding algorithm.
A SFML view project is provided to have a visual and a simple interface of the generator, allowing to play with it.
A Unity plugin is present in the Unity sample allowing to generate dungeon also in Unity.

Features :

  • Create easily a dungeon with few lines of code,
  • No restriction on dungeon size : It can be a square, or a rectangle from a width of 0 to 64000 !
  • You can define number of enemies and chests in the dungeon,
  • Rooms can be locked and keys are automatically generated with a valid path from the entrance to allow player to pick them up,
  • A Unity plugin wraps the library to allow you tu use it in Unity as easily as the C++ library.

Installation :

To use the library:

  • Link your project to the dll if you want to use the shared library;
  • Link to the lib and add the preprocessor LIBDUNGEON_STATIC if you want to use the static library.

To run the source of SFML view, or compile the library source, use Visual Studio 2015 or newer with this project.
Please install one or both of VC++15 SFML from here at path:

  • 32 bits: "$(SolutionDir)/../SFML-2.5.1"
  • 64 bits: "$(SolutionDir)/../SFML-2.5.1-x64"

If you have any issues with compilation, first check the version of windows' SDK in project properties.

To use the Unity plugin, copy the folder "Assets/Plugins/DungeonGenerator" from the sample project into your project "Assets/Plugins" folder. You can use the DungeonGenerator component directly without coding, or code yourself a C# script using the library like in C++.

C++ Library Use :

#include <DG/LibDungeon.h>

int main()
{
    // Initialization with some parameters
    DungeonParams params = DungeonParams::basic;
    params.width = 32;
    params.height = 32;
    params.roomMinWidth = 3;
    params.roomMinHeight = 3;
    params.roomMaxWidth = 15;
    params.roomMaxHeight = 15;
    Dungeon dungeon(params);


    // Generate the dungeon
    dungeon.generate();
  
    // Display dungeon values
    std::string str = "";
    for(size_t i = 0; i < params.height; i++)
    {
        for(size_t j = 0; j < params.width; j++)
        {
            str += dungeon.getValue(j, i);
        }
        str += "\n";
    }
    std::cout << str << std::endl;
  
    return 0;
}

2d-dungeon-generator's People

Contributors

benpyton avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.