tilesets.module
README.md
tilesets
Procedural generator for the twoDKit's fourteen pixel-art tile sets: grassland, cave, castle, lab, snow, desert, volcano, jungle, coast, crypt, sky, factory, candy and autumn. It paints each one into a 128x128 atlas of 16x16 tiles that follows the twoDKit.autotile layout exactly, then saves it as a nearest-filtered texture with a sprite material under twoDKit.package/art/tiles/<id>.
local Tilesets = require("twoDKit.artgen.tilesets")
Tilesets.generate() -- paint and save all fourteen (deterministic)
Tilesets.generate("snow") -- just one
local canvas = Tilesets.paint("cave") -- the atlas as a Paint canvas, not saved
print(Tilesets.ids) -- { "grassland", "cave", "castle", "lab", "snow", "desert", "volcano", "jungle", "coast", "crypt", "sky", "factory", "candy", "autumn" }
Each atlas holds:
- 0..46: blob-autotile ground tiles. A shared geometry pass works out, for each pixel, how far it is from each exposed side, then rounds the outer corners and folds the inner corners into a square (masonry) or a diagonal wedge (organic). Each set then shades from those distances: a surface cap on top (grass lip with blades, mossy rim, coping stones, hazard-striped plating, a snow drift, a sand ridge), a dark rim on the sides and bottom, light from the top-left, and its own silhouette (grass blades, a jagged cave ceiling, icicles, a castle coping lip). The interior fill is a 16 px self-seamless texture, so runs of tiles join with no seams.
- 47: a back wall, a darker, low-contrast version of the fill.
- 48..51: a one-way platform (left end, middle, right end, single), a thin ledge at the top of the cell.
- 52..55: spikes pointing up, down, left and right, each with its base on the matching edge of the cell.
- 56..63: eight decorations standing on the bottom edge of the cell, each with a 1 px outline.
To add a set, write a builder returning { round, ink, diagCorners?, fill, sil?, ground, back, platform, spike, decor } and register it in builders and ids.