# atlas.ludic — render a Kenney tile pack as one index-labeled sheet, so you can # see which sprite id is which before referring to it in a game. # # bin/ludicc --headless tools/atlas.ludic -o build/atlas # ./build/atlas < /dev/null && sips -s format png build/out.ppm --out atlas.png # # A tool written in the language it is a tool for: one Start handler draws every # tile with its number underneath and quits, and the headless build leaves the # frame in build/out.ppm. program Atlas { const DIR: string = "assets/kenney/tiny-dungeon/Tiles" const TILE_COUNT: int = 132 # tile_0000.png … tile_0131.png const COLUMNS: int = 12 const CELL: int = 24 const SPRITE_INSET_X: int = 4 # centre a 16px sprite in a 24px cell const SPRITE_INSET_Y: int = 2 const LABEL_INSET_X: int = 1 const LABEL_INSET_Y: int = 18 const BACKDROP: int = 0x101018 const LABEL_COLOR: int = 0x8090b0 # "/tile_0007.png" — the id is the file's zero-padded number function tile_path(i: int) -> string { var digits = Text.from_int(i) while Text.length(digits) < 4 { digits = "0" + digits } return `{DIR}/tile_{digits}.png` } handler Sheet phase Start { Screen.clear(BACKDROP) for i in 0 .. TILE_COUNT { let x = (i % COLUMNS) * CELL let y = (i / COLUMNS) * CELL let id = Assets.image(tile_path(i)) if id >= 0 { Screen.sprite(id, x + SPRITE_INSET_X, y + SPRITE_INSET_Y) } Screen.draw_number(x + LABEL_INSET_X, y + LABEL_INSET_Y, i, LABEL_COLOR, 1) } Screen.show() quit() } }