{"id":15315600,"url":"https://github.com/obsfx/dungrain","last_synced_at":"2025-04-15T02:18:04.489Z","repository":{"id":40867878,"uuid":"234146327","full_name":"obsfx/dungrain","owner":"obsfx","description":"BSP based procedural dungeon generation package.","archived":false,"fork":false,"pushed_at":"2022-06-22T23:35:04.000Z","size":4493,"stargazers_count":4,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T14:05:04.339Z","etag":null,"topics":["dungeon","generation","procedural","procedural-generation","rogue","roguelike","typescript"],"latest_commit_sha":null,"homepage":"https://github.com/obsfx/dungrain","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/obsfx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-15T18:31:58.000Z","updated_at":"2023-02-10T21:52:08.000Z","dependencies_parsed_at":"2022-09-07T00:04:04.323Z","dependency_job_id":null,"html_url":"https://github.com/obsfx/dungrain","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obsfx%2Fdungrain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obsfx%2Fdungrain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obsfx%2Fdungrain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obsfx%2Fdungrain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/obsfx","download_url":"https://codeload.github.com/obsfx/dungrain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248584937,"owners_count":21128915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dungeon","generation","procedural","procedural-generation","rogue","roguelike","typescript"],"created_at":"2024-10-01T08:51:11.982Z","updated_at":"2025-04-15T02:18:04.467Z","avatar_url":"https://github.com/obsfx.png","language":"JavaScript","readme":"![](https://raw.githubusercontent.com/obsfx/dungrain/master/media/logo.png)\n\n# dungrain [![npm version](https://badge.fury.io/js/dungrain.svg)](https://badge.fury.io/js/dungrain)\n\ndungrain is a procedural dungeon generation library that was built on binary space partitioning method. It takes some arguments as an object and creates 2D number array that contains types of tiles that placed based on `indexMap` (`Wall`, `Path`, `Room`, `Empty`) values.\n\n## installation\n\nYou can directly use `dungrain.js` or `dungrain.min.js` file with script tag. They can be found in build folder at github repo.\n\n```html\n\u003cscript src=\"./build/dungrain.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    let dungeon = new dungrain({\n        iterationCount: 20,\n        column: 100,\n        row: 40,\n        indexMap: {\n            Wall: 3,\n            Path: 2,\n            Room: 1,\n            Empty: 0\n        }\n    });\n\u003c/script\u003e\n```\n\nor you can install with npm.\n\n```\nnpm install dungrain\n```\n\n```javascript\nconst dungrain = require('dungrain');\n\nlet dungeon = new dungrain({\n    iterationCount: 20,\n    column: 100,\n    row: 40,\n    indexMap: {\n        Wall: 3,\n        Path: 2,\n        Room: 1,\n        Empty: 0\n    }\n});\n```\n\n## usage\n\n##### arguments\n\nAll arguments have to be passed into class as an object.\n\n```\n{\n    iterationCount: number,\n    column: number,\n    row: number,\n    indexMap: {\n        Wall: number,\n        Path: number,\n        Room: number,\n        Empty: number\n        \n    }\n\tseed: string (optional) (default: it will be generated randomly),\n\tminimumWHRatio: number (optional) (default: 0.5),\n\tmaximumWHRatio: number (optional) (default: 2.0),\n\tminimumChunkWidth: number (optional) (default: 8),\n\tminimumChunkHeight: number (optional) (default: 8)\n} \n```\n\n##### methods\n\n```javascript\ngetMap() // (returns generated dungeon that formed into 2D number array)\ngetAllFloors() // (returns all available floors included rooms and paths)\ngetRooms() // (returns all room objects that contains their topleftcorner point and all available floors array)\ngetPaths() // (returns all path objects that contains their start point, all available floors array data, direction data (0: VERTICAL, 1: HORIZONTAL) and width value (represents the length of the path))\ngetSeed() // (returns the seed of the generated dungeon)\n```\n\n\n\n## example\n\n##### code\n\n```html\n\u003ccanvas class=\"canvas\" width=\"1000\" height=\"500\"\u003e\u003c/canvas\u003e\n\n\u003cscript src=\"./build/dungrain.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n\tlet canvas = document.querySelector('.canvas');\n\tlet ctx = canvas.getContext('2d');\n\t\n\tlet dungeon = new dungrain({\n\t\tseed: 'example',\n\t\titerationCount: 6,\n\t\tcolumn: 100,\n\t\trow: 50,\n\t\tindexMap: {\n\t\t\tWall: 3,\n\t\t\tPath: 2,\n\t\t\tRoom: 1,\n\t\t\tEmpty: 0\n\t\t},\n\t\tminimumWHRatio: 0.8,\n\t\tmaximumWHRatio: 1.6,\n\t\tminimumChunkWidth: 2,\n\t\tminimumChunkHeight: 2\n\t});\n\n\tlet map = dungeon.getMap();\n\n\tfor (let i = 0; i \u003c map.length; i++) {\n\t\tfor (let j = 0; j \u003c map[i].length; j++) {\n\t\t\tlet tile = map[i][j];\n\n\t\t\tif (tile == dungeon.indexMap.Wall) {\n\t\t\t\tctx.fillStyle = 'black';\n\t\t\t} else if (tile == dungeon.indexMap.Path) {\n\t\t\t\tctx.fillStyle = 'blue';\n\t\t\t} else if (tile == dungeon.indexMap.Room) { \n\t\t\t\tctx.fillStyle = 'green';\n\t\t\t} else {\n\t\t\t\tctx.fillStyle = 'white';\n\t\t\t}\n\n\t\t\tctx.fillRect(j * 10, i * 10, 10, 10);\n\t\t}\n\t}\n\u003c/script\u003e\n```\n\n##### output\n\n![](https://raw.githubusercontent.com/obsfx/dungrain/master/media/example.png)\n\n\n\n##### see in action @codepen\n\ni made a codepen visualization demo with early version of this. You can play with that from here: https://codepen.io/omercanbalandi/pen/JjoeKrQ\n\n![](https://raw.githubusercontent.com/obsfx/dungrain/master/media/codepen.gif)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobsfx%2Fdungrain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fobsfx%2Fdungrain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobsfx%2Fdungrain/lists"}