{"id":13569607,"url":"https://github.com/SolarLune/dngn","last_synced_at":"2025-04-04T05:33:16.269Z","repository":{"id":57480699,"uuid":"156150040","full_name":"SolarLune/dngn","owner":"SolarLune","description":"A Golang library for random map generation for games.","archived":false,"fork":false,"pushed_at":"2024-07-24T22:42:03.000Z","size":82,"stargazers_count":134,"open_issues_count":3,"forks_count":18,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-08-02T14:06:50.681Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SolarLune.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-05T02:35:04.000Z","updated_at":"2024-07-25T03:10:41.000Z","dependencies_parsed_at":"2024-01-14T03:47:38.411Z","dependency_job_id":"1df0e113-1ba7-4262-8613-dbee12264474","html_url":"https://github.com/SolarLune/dngn","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Fdngn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Fdngn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Fdngn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Fdngn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SolarLune","download_url":"https://codeload.github.com/SolarLune/dngn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223100124,"owners_count":17087387,"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":[],"created_at":"2024-08-01T14:00:41.889Z","updated_at":"2024-11-05T01:32:50.900Z","avatar_url":"https://github.com/SolarLune.png","language":"Go","funding_links":[],"categories":["Go","Procedural Content Genration"],"sub_categories":[],"readme":"\n# dngn\n\n![dngn_v0.2](https://user-images.githubusercontent.com/4733521/48660612-68e94480-ea19-11e8-8f4d-b378fa64dabe.gif)\n\n[pkg.go.dev docs](https://pkg.go.dev/github.com/SolarLune/dngn?tab=doc)\n\n## What is dngn?\n\ndngn is a golang library specifically created to help make generating random maps easier. This does not create maps from hand-crafted pieces randomly slotted together, but rather generates cellular rooms in a grid.\n\n## Why is it called that?\n\nBecause it's short, simple, and to the point. Also, vwls r vrrtd.\n\n## Why did you create dngn?\n\nBecause I needed to do random map generation for a game and didn't seem to find a library around anywhere.\n\nAnd so, here we are.\n\n## How do I install it?\n\nJust go get it and import it in your game application.\n\n`go get github.com/solarlune/dngn`\n\nOr import and use it directly in your code with a `go.mod` file in your project directory, and it will go ahead and automatically download it and use it for your project. [See the Go wiki.](https://github.com/golang/go/wiki/Modules#quick-start)\n\n## How do I use it?\n\ndngn is based around Layouts and Selections. A Layout contains a rune array, which is the internal data. You can either manipulate the data array manually, or use Selections to grab a selection of cells in the Layout to alter. Layouts have Generate functions to generate a game map; they each take different arguments to influence how the function generates a map. To start off, you can just create a Layout, and then use one of the included `Generate` functions to generate the data:\n\n```go\nimport \"github.com/solarlune/dngn\"\n\nvar GameMap *dngn.Layout\n\nfunc Init() {\n\n    // This line creates a new *dngn.Layout. The size is 10x10.\n    GameMap = dngn.NewLayout(10, 10)\n\n    // This will generate a map using BSP map generation and some sensible default settings.\n    GameMap.GenerateBSP(dngn.NewDefaultBSPOptions())\n\n    // Layout.DataToString() will present the data in a nice, easy-to-understand visual format, useful when debugging.\n    fmt.Println(GameMap.DataToString())\n\n    // Now we're done! We can visualize and use the Layout.\n\n}\n\n```\n\nAfter generating the Layout, Selections can be used to filter out pieces of the Layout to alter them. Selections can also be chained together. As an example, say you wanted to randomly change a small percentage of floor tiles (' ') into trap tiles ('z'). You could easily do this with Selections, like so:\n\n```go\n    GameMap.Select().FilterByValue(' ').FilterByPercentage(0.1).Fill('z')\n```\n\n---\n\nAnd that's about it! There are also some nice additional features to make it easier to handle working with and altering Layouts directly.\n\n## Wait... How do I actually LOOK at it?\n\ndngn just does map generation - it doesn't handle visualization / rendering of the map. For that, you can use another framework, like [pixel](https://github.com/faiface/pixel), [Ebiten](https://github.com/hajimehoshi/ebiten), [raylib-goplus](https://github.com/Lachee/raylib-goplus), or [go-sdl2](https://github.com/veandco/go-sdl2).\n\nThat's about it. You can run the example by simply running the example from the project's root directory:\n\n```\n$ go run ./example/\n```\n\n[pkg.go.dev docs](https://pkg.go.dev/github.com/SolarLune/dngn?tab=doc)\n\n## Dependencies?\n\nFor the actual package, there are no external dependencies. dngn just uses the built-in \"fmt\" and \"math\" packages.\n\nFor the tests, dngn requires [Ebiten](https://github.com/hajimehoshi/ebiten) to create the window, handle input, and draw the shapes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSolarLune%2Fdngn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSolarLune%2Fdngn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSolarLune%2Fdngn/lists"}