JSPM

@ziagl/tiled-map-generator

1.2.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q23768F
  • License GNU LESSER GENERAL PUBLIC LICENSE

A map generator for Tiled map editor file format

Package Exports

  • @ziagl/tiled-map-generator
  • @ziagl/tiled-map-generator/lib/main/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ziagl/tiled-map-generator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

tiled-map-generator

A map generator for Tiled Map Editor (https://www.mapeditor.org/) files.

Sample of generated maps inside Tiled Map Editor:

Type: CONTINENTS_ISLANDS, Size: TINY Alt text

Sample code to create map

const fs = require('fs');
const tmg = require('@ziagl/tiled-map-generator');

// generate a new map
let generator = new tmg.Generator();
generator.generateMap(tmg.MapType.CONTINENTS_ISLANDS, tmg.MapSize.TINY);
const [map, rows, columns] = generator.exportMap();

// convert this map into a 2d array
let converter = new tmg.Converter();

// option 1: store it in a new json file based on example.json
const data = fs.readFileSync('example.json', 'utf8');
const result = converter.convertToTiled(map, rows, columns, data);

// option 2: create a new json string without template
const result = converter.generateTiledJson(map, rows, columns, 'tileset.png', 32, 34, 416, 34, 13, 13, "#ffffff");

fs.writeFileSync('map.json', result, 'utf-8', (err) => {
    if (err) {
        console.error('Error while writing map file:', err);
    }
});

// print out map as debug output on console
console.log(generator.print());

All possible map types as example images:

Type: ARCHIPELAGO, Size: TINY Alt text

Type: CONTINENTS, Size: TINY Alt text

Type: HIGHLAND, Size: TINY Alt text

Type: INLAND_SEA, Size: TINY Alt text

Type: ISLANDS, Size: TINY Alt text

Type: LAKES, Size: TINY Alt text

Type: SMALL_CONTINENTS, Size: TINY Alt text

Type: SUPER_CONTINENT, Size: TINY Alt text