diff --git a/assets/_sources/_gen.js b/assets/_sources/_gen.js new file mode 100644 index 0000000..6768a36 --- /dev/null +++ b/assets/_sources/_gen.js @@ -0,0 +1,21 @@ +const { PNG } = require('pngjs'); +const fs = require('node:fs'); +const path = require('node:path'); + +function writeSolidRGBA(p, w, h, rgba) { + const png = new PNG({ width: w, height: h }); + for (let i = 0; i < png.data.length; i += 4) { + png.data[i + 0] = rgba[0]; + png.data[i + 1] = rgba[1]; + png.data[i + 2] = rgba[2]; + png.data[i + 3] = rgba[3]; + } + fs.writeFileSync(p, PNG.sync.write(png)); +} + +const SOURCES = path.resolve(__dirname); +writeSolidRGBA(path.join(SOURCES, 'demo_tilemap', 'grass_diffuse.png'), 32, 32, [110, 170, 80, 255]); +writeSolidRGBA(path.join(SOURCES, 'demo_tilemap', 'stone_diffuse.png'), 32, 32, [120, 120, 120, 255]); +writeSolidRGBA(path.join(SOURCES, 'walls_tilemap', 'wall_brick_diffuse.png'), 32, 32, [180, 100, 80, 255]); +writeSolidRGBA(path.join(SOURCES, 'walls_tilemap', 'wall_wood_diffuse.png'), 32, 32, [140, 90, 50, 255]); +console.log('test-stub sources generated'); diff --git a/assets/_sources/demo_tilemap/grass_diffuse.png b/assets/_sources/demo_tilemap/grass_diffuse.png new file mode 100644 index 0000000..da75774 Binary files /dev/null and b/assets/_sources/demo_tilemap/grass_diffuse.png differ diff --git a/assets/_sources/demo_tilemap/stone_diffuse.png b/assets/_sources/demo_tilemap/stone_diffuse.png new file mode 100644 index 0000000..7991b4c Binary files /dev/null and b/assets/_sources/demo_tilemap/stone_diffuse.png differ diff --git a/assets/_sources/walls_tilemap/wall_brick_diffuse.png b/assets/_sources/walls_tilemap/wall_brick_diffuse.png new file mode 100644 index 0000000..7811e7c Binary files /dev/null and b/assets/_sources/walls_tilemap/wall_brick_diffuse.png differ diff --git a/assets/_sources/walls_tilemap/wall_wood_diffuse.png b/assets/_sources/walls_tilemap/wall_wood_diffuse.png new file mode 100644 index 0000000..69085d1 Binary files /dev/null and b/assets/_sources/walls_tilemap/wall_wood_diffuse.png differ diff --git a/assets/atlases/demo_tilemap/tiles.atlas.json b/assets/atlases/demo_tilemap/tiles.atlas.json new file mode 100644 index 0000000..35688da --- /dev/null +++ b/assets/atlases/demo_tilemap/tiles.atlas.json @@ -0,0 +1,31 @@ +{ + "atlas_id": "demo_tilemap", + "atlas_version": 1, + "atlas_size_px": [ + 64, + 64 + ], + "tile_size_px": 32, + "tiles": [ + { + "id": 1, + "name": "grass", + "uv": [ + 0, + 0, + 32, + 32 + ] + }, + { + "id": 2, + "name": "stone", + "uv": [ + 32, + 0, + 32, + 32 + ] + } + ] +} diff --git a/assets/atlases/demo_tilemap/tiles.atlas.lock.json b/assets/atlases/demo_tilemap/tiles.atlas.lock.json new file mode 100644 index 0000000..b06ca88 --- /dev/null +++ b/assets/atlases/demo_tilemap/tiles.atlas.lock.json @@ -0,0 +1,9 @@ +{ + "atlas_id": "demo_tilemap", + "bindings": { + "grass": 1, + "stone": 2 + }, + "deleted": [], + "next_id": 3 +} diff --git a/assets/atlases/demo_tilemap/tiles.diffuse.atlas.png b/assets/atlases/demo_tilemap/tiles.diffuse.atlas.png new file mode 100644 index 0000000..82f2d3d Binary files /dev/null and b/assets/atlases/demo_tilemap/tiles.diffuse.atlas.png differ diff --git a/assets/atlases/demo_tilemap/tiles.height.atlas.png b/assets/atlases/demo_tilemap/tiles.height.atlas.png new file mode 100644 index 0000000..a5d5cf1 Binary files /dev/null and b/assets/atlases/demo_tilemap/tiles.height.atlas.png differ diff --git a/assets/atlases/walls_tilemap/tiles.atlas.json b/assets/atlases/walls_tilemap/tiles.atlas.json new file mode 100644 index 0000000..f7fe07a --- /dev/null +++ b/assets/atlases/walls_tilemap/tiles.atlas.json @@ -0,0 +1,33 @@ +{ + "atlas_id": "walls_tilemap", + "atlas_version": 1, + "atlas_size_px": [ + 64, + 64 + ], + "tile_size_px": 32, + "tiles": [ + { + "id": 1, + "name": "wall_brick", + "uv": [ + 0, + 0, + 32, + 32 + ], + "blocks_sight": true + }, + { + "id": 2, + "name": "wall_wood", + "uv": [ + 32, + 0, + 32, + 32 + ], + "blocks_sight": true + } + ] +} diff --git a/assets/atlases/walls_tilemap/tiles.atlas.lock.json b/assets/atlases/walls_tilemap/tiles.atlas.lock.json new file mode 100644 index 0000000..8082971 --- /dev/null +++ b/assets/atlases/walls_tilemap/tiles.atlas.lock.json @@ -0,0 +1,9 @@ +{ + "atlas_id": "walls_tilemap", + "bindings": { + "wall_brick": 1, + "wall_wood": 2 + }, + "deleted": [], + "next_id": 3 +} diff --git a/assets/atlases/walls_tilemap/tiles.diffuse.atlas.png b/assets/atlases/walls_tilemap/tiles.diffuse.atlas.png new file mode 100644 index 0000000..dbf9572 Binary files /dev/null and b/assets/atlases/walls_tilemap/tiles.diffuse.atlas.png differ diff --git a/assets/atlases/walls_tilemap/tiles.height.atlas.png b/assets/atlases/walls_tilemap/tiles.height.atlas.png new file mode 100644 index 0000000..a5d5cf1 Binary files /dev/null and b/assets/atlases/walls_tilemap/tiles.height.atlas.png differ diff --git a/assets/tiles/demo_tilemap.tilemap.json b/assets/tiles/demo_tilemap.tilemap.json deleted file mode 100644 index a5381d2..0000000 --- a/assets/tiles/demo_tilemap.tilemap.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "demo_tilemap", - "tile_size": 32, - "tiles": [ - {"id": "grass", "walkable": true, "color": [110, 170, 80]}, - {"id": "stone", "walkable": false, "color": [120, 120, 120]} - ] -} diff --git a/assets/tiles/walls_tilemap.tilemap.json b/assets/tiles/walls_tilemap.tilemap.json deleted file mode 100644 index 3db2075..0000000 --- a/assets/tiles/walls_tilemap.tilemap.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "walls_tilemap", - "tile_size": 32, - "tiles": [ - {"id": "wall_brick", "walkable": false, "color": [180, 100, 80]}, - {"id": "wall_wood", "walkable": false, "color": [140, 90, 50]} - ] -} diff --git a/scripts/bake.sh b/scripts/bake.sh new file mode 100644 index 0000000..23a79da --- /dev/null +++ b/scripts/bake.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Re-bake the stub atlases used by maps-test fixtures. +set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +LIB_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" +BAKER=~/Projects/Sporel/sporel-tool-atlas-baker/bin/atlas-baker.js + +node "$BAKER" \ + --in "$LIB_DIR/assets/_sources/demo_tilemap" \ + --out "$LIB_DIR/assets/atlases/demo_tilemap" \ + --atlas-id demo_tilemap \ + --tile-size 32 + +node "$BAKER" \ + --in "$LIB_DIR/assets/_sources/walls_tilemap" \ + --out "$LIB_DIR/assets/atlases/walls_tilemap" \ + --atlas-id walls_tilemap \ + --tile-size 32 \ + --blocks-sight-pattern '^wall_'