tilemap

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Up    = image.Point{0, -1} // {0, -1}
	Down  = image.Point{0, 1}  // {0, 1}
	Left  = image.Point{-1, 0} // {-1, 0}
	Right = image.Point{1, 0}  // {1, 0}
)

Functions

func MakeGrid

func MakeGrid(width, height int) [][]uint8

Types

type Generator

type Generator struct {
	NoiseState *fastnoise.State[float64]
	PCG        *rand.PCG
	Rand       *rand.Rand
	Opts       *WorldOpts
	Tilemap    TileMap
}

func NewGenerator

func NewGenerator(t TileMap) Generator

func (*Generator) CoalOreLayer

func (g *Generator) CoalOreLayer(n int)

func (*Generator) DiamondOreLayer

func (g *Generator) DiamondOreLayer(n int)

func (*Generator) FillBedrockLayer

func (g *Generator) FillBedrockLayer()

func (*Generator) Generate

func (g *Generator) Generate()

func (*Generator) GoldOreLayer

func (g *Generator) GoldOreLayer(n int)

func (*Generator) IronOreLayer

func (g *Generator) IronOreLayer(n int)

func (*Generator) RandomPointInRect

func (g *Generator) RandomPointInRect(rect image.Rectangle) (int, int)

func (*Generator) SetSeed

func (g *Generator) SetSeed(seed int)

func (*Generator) StoneLayer

func (g *Generator) StoneLayer()

func (*Generator) Surface

func (g *Generator) Surface()

type TileMap

type TileMap struct {
	Grid         [][]uint8
	W, H         int
	TileW, TileH int
}

func MakeTileMap

func MakeTileMap(w, h, tileW, tileH int) TileMap

func (*TileMap) FindSpawnPosition

func (t *TileMap) FindSpawnPosition() image.Point

func (*TileMap) FindSpawnPosition2

func (t *TileMap) FindSpawnPosition2(x, y int) image.Point

func (*TileMap) FloorToBlockCenter

func (t *TileMap) FloorToBlockCenter(x, y float64) v.Vec

func (*TileMap) GetID

func (t *TileMap) GetID(x, y int) uint8

func (*TileMap) GetIDUnchecked

func (t *TileMap) GetIDUnchecked(coords image.Point) uint8

func (*TileMap) GetImage

func (tm *TileMap) GetImage() *image.RGBA

func (*TileMap) GetImageByte

func (t *TileMap) GetImageByte() []byte

func (*TileMap) GetTileBottom

func (t *TileMap) GetTileBottom(x, y int) float64

func (*TileMap) GetTileRect

func (t *TileMap) GetTileRect(x, y int) (rectX, rectY, rectW, rectH float64)

func (*TileMap) Raycast

func (t *TileMap) Raycast(pos image.Point, dirX, dirY, dist int) (image.Point, bool)

func (*TileMap) Set

func (t *TileMap) Set(x, y int, id uint8)

func (*TileMap) SetUnchecked

func (t *TileMap) SetUnchecked(coord image.Point, id uint8)

func (*TileMap) TileIDProperty

func (t *TileMap) TileIDProperty(x, y int) items.ItemProperty

func (*TileMap) TileToWorld

func (t *TileMap) TileToWorld(p image.Point) v.Vec

Tile coords to block center

func (*TileMap) WorldToTile

func (t *TileMap) WorldToTile(x, y float64) image.Point

func (*TileMap) WorldToTile2

func (t *TileMap) WorldToTile2(x, y float64) (int, int)

type WorldOpts

type WorldOpts struct {
	Seed                int
	SurfaceFlatness     float64
	HighestSurfaceLevel float64
	LowestSurfaceLevel  float64
	HighestGoldLevel    float64
	LowestGoldLevel     float64
	HighestIronLevel    float64
	LowestIronLevel     float64
	HighestCoalLevel    float64
	LowestCoalLevel     float64
	HighestDiamondLevel float64
	LowestDiamondLevel  float64
}

func DefaultWorldOpts

func DefaultWorldOpts() WorldOpts

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL