
Research
/Security News
DuckDB npm Account Compromised in Continuing Supply Chain Attack
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
github.com/solarlune/dngn
dngn 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.
Because it's short, simple, and to the point. Also, vwls r vrrtd.
Because I needed to do random map generation for a game and didn't seem to find a library around anywhere.
And so, here we are.
Just go get it and import it in your game application.
go get github.com/solarlune/dngn
Or 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.
dngn 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:
import "github.com/solarlune/dngn"
var GameMap *dngn.Layout
func Init() {
// This line creates a new *dngn.Layout. The size is 10x10.
GameMap = dngn.NewLayout(10, 10)
// This will generate a map using BSP map generation and some sensible default settings.
GameMap.GenerateBSP(dngn.NewDefaultBSPOptions())
// Layout.DataToString() will present the data in a nice, easy-to-understand visual format, useful when debugging.
fmt.Println(GameMap.DataToString())
// Now we're done! We can visualize and use the Layout.
}
After 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:
GameMap.Select().FilterByValue(' ').FilterByPercentage(0.1).Fill('z')
And that's about it! There are also some nice additional features to make it easier to handle working with and altering Layouts directly.
dngn just does map generation - it doesn't handle visualization / rendering of the map. For that, you can use another framework, like pixel, Ebiten, raylib-goplus, or go-sdl2.
That's about it. You can run the example by simply running the example from the project's root directory:
$ go run ./example/
For the actual package, there are no external dependencies. dngn just uses the built-in "fmt" and "math" packages.
For the tests, dngn requires Ebiten to create the window, handle input, and draw the shapes.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.