Giter Site home page Giter Site logo

tiledjson's Introduction

Introduction

C++11 Tiled map loader that uses the JSON export format instead of the TMX.

tiledjson is not a Tiled map renderer, nor is it built with any specific framework, library, or engine in mind.

What it is is an object-oriented approach to loading and accessing Tiled maps that are in the JSON format.

Using tiledjson in your project

The recommended approach to integrating tiledjson in your project is to include the source and header files in your project, and compile and build as you would any other source file.

The only external dependency for tiledjson is JsonCpp. JsonCpp is used by the JsonTMXImporter class to parse the JSON files. Using JsonCpp's amalgamated source and header is very simple and the recommended approach.

Quick Start

Start by exporting your map's TMX file to JSON. In Tiled, goto:

- File
  - Export As (Ctrl-E)

And select json map files (*.json) from the "Save as type" drop down. You will also need to make sure you have the map's property "Tile Layer Format" set to "CSV". This is because zlib compression is not supported; this will hopefully be unnecessary in the near future.

Using tiledjson is fairly simple:

// Create TiledMap object
tiledjson::TiledMap theMap;

// Tell it to load a map from a file.
theMap.loadFromFile("path/to/level.json");

That will attempt to open and parse the JSON file and load the data into the TiledMap object, using the included LevelImporter, JsonTMXImporter.

Custom Level Importers

In order to load map data into the TiledMap class, an importer is needed. Importers inherit from LevelImporter. JsonTMXImporter is included as part of tilejson, however you should be able to write your own custom importer, inheriting from LevelImporter, and use it instead.

Example:

// Create your own importer class, inheriting from LevelImporter.
// Then, create it and load your level data.
MyMapImporter* myImporter = new MyMapImporter();
myImporter->load("path/to/map.file");

// Now, use that custom importer with TiledMap.
tiledjson:TiledMap theMap;
theMap.loadFromImporter(myImporter);

Features

  • Loads Tiled maps that are exported in the JSON format
  • Layer support:
    • Tile layers
    • Object layers
    • Image layers
  • Property Support:
    • Map
    • Layer
    • Object
    • Tile
  • Objects:
    • Rectangle
    • Polyline

Roadmap

  • zlib support for tile layers
  • Better way to handle properties
  • Object: Ellipse support

License

See the LICENSE file for details. In summary, tiledjson is licensed under the MIT license, or public domain if desired and recognized in your jurisdiction.

tiledjson's People

Contributors

lxndrdagreat avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Forkers

enigmanark

tiledjson's Issues

Update Description and Code for latest jsoncpp release

Hi there,

I just downloaded tiledjson since I figured there was no point in reinventing the wheel if a suitable library already exists for my needs.

However, in order to work with the latest version of jsoncpp, JsonTMXImporter.cpp needs to be updated at lines 49 and 152 to fix a compile error to what I'm assuming was a type deprecation in how their classes worked.

The fix is to replace JSON::ValueIterator with JSON::Value::const_iterator and that does the trick just fine.

Another quick issue I discovered whilst trying to import my file is that the instructions for importing a json map is different to what is listed in the readme. It seems that you can no longer pass in a filepath to the TiledMap constructor, instead you have to create the TiledMap and call loadFromFile ( filepath ) instead.

That's all I've noticed so far!

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.