Skip to content

glouw/dungen

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
img
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Delaunay Triangulation Dungeon Generator.

>> Inspired by Tiny Keep's dungeon generator.

Use case:

#include "Map.h"

int main()
{
    const Map map = xmgen(80, 120, 10, 40);
    xmprint(map);
    xmclose(map);
}

Where the map generation function is defined as:

Map xmgen(
        number of columns,
        number of rows,
        size of grid,
        max number of rooms);

Generated map is stored as a 2D array of characters.

Here's what it looks like:

#############################################################
###########         #         #         #         ###########
##       ##         #         #         #         ###########
##       ##         #         #         #         #         #
##       ##         #         #         #         #         #
##                                                          #
##       ##         #         #         #         #         #
##       ##         #         #         #         #         #
##       ##         #         #         #         ##### #####
###########         #         #         #         ##### #####
############### ################### ################### #####
############### ###############         #         ##       ##
#############     #############         #         ##       ##
###########         ###########         #         #         #
###########         ###########         #         #         #
###########         ###########                             #
###########         ###########         #         #         #
###########         ###########         #         #         #
#############     #############         #         ##       ##
############### ###############         #         ##       ##
############### ############################# ######### #####
###     #####     ########################       ####     ###
###     #####     ####       #############       ###       ##
###     ###         ##       #############       ##         #
###     ###         ##       #############       ##         #
###                          #############                  #
###     ###         ##       #############       ##         #
###     ###         ##       #############       ##         #
###     #####     ####       #############       ###       ##
###     #####     ####### ################       ####     ###
##### ######### ######### ############################# #####
#         #         ##### ######       ###       ####     ###
#         #         ##       ###       ###       ####     ###
#         #         ##       ###       ###       ####     ###
#         #         ##       ###       ###       ####     ###
#                   ##                                    ###
#         #         ##       ###       ###       ####     ###
#         #         ##       ###       ###       ####     ###
#         #         ##       ###       ###       ####     ###
#         #         ############       ###       ####     ###
##### #######################################################
##### ######       ###       ################################
##       ###       ###       ################################
##       ###       ###       ################################
##       ###       ###       ################################
##                           ################################
##       ###       ###       ################################
##       ###       ###       ################################
##       ###       ###       ################################
############       ###       ################################
############### ######### ###################################
############       ###       ##############     #############
############       ###       ##############     #####     ###
############       ###       ##############     ####       ##
############       ###       ##############     ####       ##
############       ###       ##############                ##
############       ###       ##############     ####       ##
############       ###       ##############     ####       ##
############       ###       ##############     #####     ###
############       ###       ##############     ####### #####
############### ######### ################### ######### #####
#         ###     ####       ##############     ####### #####
#         ##       ##         #         ###     ####       ##
#         ##       ##         #         ##       ###       ##
#         ##       ##         #         ##       ###       ##
#                                       ##       ###       ##
#         ##       ##         #         ##       ###       ##
#         ##       ##         #         ##       ###       ##
#         ##       ##         #         ###     ####       ##
#         ###     ####       ###### #######     ####### #####
##### ############################# ######### ######### #####
#         ######################### ######### #####         #
#         #######################     #####     ###         #
#         #######################     ####       ##         #
#         #######################     ####       ##         #
#         #######################                           #
#         #######################     ####       ##         #
#         #######################     ####       ##         #
#         #######################     #####     ###         #
#         #########################################         #
##### ################################################# #####
##### #####         ###     #####     #############         #
#         #         ##       ####     #############         #
#         #         ##       ####     #############         #
#         #         ##       ####     #############         #
#                                     #############         #
#         #         ##       ####     #############         #
#         #         ##       ####     #############         #
#         #         ##       ####     #############         #
###########         ###     #####     #############         #
############### ######### ######### ################### #####
###########         ##### #####         #         ##### #####
###########         ##       ##         #         ##       ##
###########         ##       ##         #         ##       ##
###########         ##       ##         #         ##       ##
###########         ##       ##                            ##
###########         ##       ##         #         ##       ##
###########         ##       ##         #         ##       ##
###########         ##       ##         #         ##       ##
###########         ###########         #         ###########
#############################################################

Credit to Phi Dinh for the awesome algorithm.