• Stars
    star
    134
  • Rank 270,967 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created about 6 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Golang library for random map generation for games.

dngn

dngn_v0.2

pkg.go.dev docs

What is 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.

Why is it called that?

Because it's short, simple, and to the point. Also, vwls r vrrtd.

Why did you create dngn?

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.

How do I install it?

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.

How do I use it?

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.

Wait... How do I actually LOOK at it?

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/

pkg.go.dev docs

Dependencies?

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.

More Repositories

1

masterplan

MasterPlan is a project management software / visual idea board software. It attempts to be easy to use, lightweight, and fun.
Go
509
star
2

resolv

A Simple 2D Golang collision detection and resolution library for games
Go
425
star
3

tetra3d

Tetra3D is a 3D hybrid software/hardware renderer made for games written in Go with Ebitengine.
Go
383
star
4

ldtkgo

LDtk-Go is a loader for LDtk projects written in Golang.
Go
89
star
5

paths

paths is a pathfinding library written in Golang for use with games.
Go
59
star
6

goaseprite

Aseprite JSON loader for Go (Golang)
Go
51
star
7

cando

A simple Finite State Machine for Golang.
Go
34
star
8

tetraterm

TetraTerm is a terminal debugging and visualization app for Tetra3D applications.
Go
18
star
9

resound

Resound is a library for applying sound effects to Ebitengine games and controlling sound playback easily.
Go
17
star
10

Grout

Grout is a manual window tiling script for Linux.
Python
14
star
11

gocoro

gocoro is a package for coroutines, implemented in Go.
Go
14
star
12

bdx

A cross-platform game engine for Blender 3D
Java
11
star
13

SolHelp

[ARCHIVED]
Python
10
star
14

ebitick

ebitick is a timer system for Ebitengine games.
Go
9
star
15

LearningGoGamedev

A learning resource for making games in Golang
Go
9
star
16

routine

Routine is a Go package for running routines, primarily for game development.
Go
9
star
17

Pop-64-Example

A 3D Platformer test game for Godot
GDScript
9
star
18

messages

Messages is a golang library tuned for gamedev for subscribing to and passing messages between relevant objects.
Go
5
star
19

tetra3d-quickstart

A quickstart project for use with Tetra3D.
Go
3
star
20

egpbc

egpbc is a gamepad constant library for Ebitengine games.
Go
3
star
21

LDJam46

A game that I started for LDJam46, which had the theme Keep It Alive.
Go
3
star
22

BDXHelper

A set of additional helper modules for BDX, the Blender-integrated LibGDX-powered open-source cross-platform 3D game engine.
Java
3
star
23

gooey

Go
3
star
24

bdx_package.py

A distribution script for LibGDX-based applications.
Python
2
star
25

Scratchboard

A scratchboard.
2
star
26

tetraflow

TetraFlow is a package to help create a simple game-engine-like flow for Tetra3D projects.
Go
2
star