caves

command
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 4 Imported by: 0

README

# Caves (procedural generation)

demo

Explore a cave that never existed before you ran the game, and collect every gem. Winning generates a brand new cave.

cd examples/caves
go run .

WASD or arrow keys to move.

What this example proves

Procedural generation needs nothing from the engine; it is plain Go code that ends in scene.Add calls:

  • Cellular automata (scripts/mapgen.go): random fill, then four smoothing passes where crowded cells become wall and lonely walls erode. Classic cave shapes in ~40 lines, no engine types involved.
  • BFS flood fill from the player's spawn: gems are placed only on reachable cells, so every generated cave is guaranteed winnable.
  • Wall merging: horizontal runs of wall cells collapse into single solid rects, cutting hundreds of objects down to dozens with identical geometry.
  • Runtime rebuild: the whole map is destroyed and regenerated between rounds with ordinary Destroy and Add calls, no special level-loading machinery.

Documentation

Overview

Caves: explore a procedurally generated cave and collect every gem. Each round generates a brand new cave (cellular automata), places the player near the center and scatters gems only in reachable areas (BFS flood fill), so every cave is winnable.

Run from this folder: cd examples/caves && go run .

Directories

Path Synopsis
Package scripts holds the map generation for Caves: pure algorithms, no engine types.
Package scripts holds the map generation for Caves: pure algorithms, no engine types.

Jump to

Keyboard shortcuts

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