• Stars
    star
    359
  • Rank 118,537 (Top 3 %)
  • Language
    C++
  • License
    Other
  • Created about 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

lightweight C++14 parser for Tiled tmx files

tmxlite

Github Actions

Description

A lightweight C++14 parsing library for tmx map files created with the Tiled map editor. Requires no external linking, all dependencies are included. Optionally Zstd support can be enabled by linking the required external library. Fully supports tmx maps up to 1.0 (see here) with CSV, zlib and base64 compression. Also supports some features of newer map versions (see below). The parser is renderer agnostic, and is cross platform on Windows, linux and macOS. It has also been successfully built for Android too.

As the library contains no specific rendering functions some example projects are included, along with the relevant CMake files. These are meant mostly for guidance and are not 100% optimised, but should get you off on the right foot when using libraries such as SFML or SDL2/OpenGL. Examples for any specific rendering library are welcome via a pull request.

Other Features

As well as full support for maps up to version 1.0, tmxlite also supports these features found in newer versions of the tmx specification:

  • Object Templates - Templates (and any associated tile sets) are automatically loaded and parsed if found. Object properties are transparently handled so that objects can be read from an ObjectGroup as if they were unique instances. If an Object uses a templated tileset then Object::getTilsetName() will contain a non-empty string which can be used as a key with Map::getTemplateTilesets() to retrieve the associated tileset data.
  • Infinite Maps - Maps with the 'infinite' flag set, and saved in either CSV or base64 (compressed and uncompressed) format are supported. A TileLayer will return an empty Tile vector in these cases, and tile ID data can be retrieved instead with TileLayer::getChunks() which returns a vector of chunk data that makes up the tile layer.
  • Parallax layers - the parallax offset property of layers is parsed, as well as each map's parallax origin, if they exist
  • Layer tint colours
  • Extended tag support such as class

By default tmxlite supports zlib compressed maps, however gzip and zstd compression can be enabled at compile time, by linking the relevant external libraries:

Zstd compression

Tmxlite supports maps using Zstd compressed tile layers, however Zstd needs to be linked externally. To configure CMake or meson to use Zstd add the definition USE_ZSTD and set it to true. You may also configure your project manually, and add -DUSE_ZSTD to the compiler options. If you are using the USE_EXTLIBS option (see below) this is automatically configured for you.

Building

Either use the included Visual Studio project file if you are on Windows or the CMake file to generate project files for your compiler of choice. tmxlite can be built as both static or shared libraries, or simply include the source files in your own project. The following options are available for CMake configuration:

  • TMXLITE_STATIC_LIB - Set this to true to build a static library, default false
  • PROJECT_STATIC_RUNTIME - Statically link the cstd libraries, default false
  • USE_RTTI - Enable runtime type information, default true
  • USE_EXTLIBS - Use externally linked pugixml, zlib and Zstd libraries, default false
  • USE_ZSTD - Use externally linked Zstd library, required for Zstd compressed maps. Default is false, but is overridden if USE_EXTLIBS is true

Configuring with meson is also possible, see meson_options.txt for details.

Quick Start

There is a getting started page on the Github wiki here.

Examples

Check out the following examples:

API Documentation

Doxygen generated API documentation can be found online here or generated with doxygen using the doxy file in the tmxlite/documentation/ directory.

Important information

tmxlite uses pugixml and miniz which are included in the repository, although external zlib and pugixml libraries can be used. Add -DUSE_EXTLIBS to your compiler's definitions or when configuring CMake set USE_EXTLIBS to TRUE. This will also automatically include Zstd.


(c)Matt Marchant & contributors 2016 - 2023 http://trederia.blogspot.com

tmxlite - Zlib license.

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.

Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

This notice may not be removed or altered from any source distribution.


A big thanks goes to all who have contributed to tmxlite via the github community.

More Repositories

1

xygine

2D engine / framework built around SFML
C++
217
star
2

sfml-tmxloader

SFML 2.x based tmx tilemap parser for files created with Tiled tile map editor
C++
105
star
3

crogine

SDL2 Based Game Framework
C++
55
star
4

pseuthe

Casual Survival Game
C++
47
star
5

crush

2D Competitive Platform Game written using C++ / SFML
C++
45
star
6

sdl2vs

Example Visual Studio Solution for SDL2 projects on Android.
Java
34
star
7

osgc

Open Source Game Collection - mini games created with xygine and SFML!
C++
22
star
8

xyExperimental

Experimental projects made with xygine
C++
11
star
9

CHIP8

A CHIP-8 interpreter for SFML supported platforms
C++
10
star
10

gp3d-water

Source to accompany article on creating water in OpenGL
C++
8
star
11

sfchat

Simple network chat protocol built on SFML
C++
7
star
12

CHUF

Carefully Handcrafted Unnamed Framework
C++
6
star
13

spin

Intel 8080 emulator
C++
5
star
14

LunarMooner

Simple arcade game built with xygine and SFML
C++
4
star
15

scratchvaders

sound powered space invaders!
C++
3
star
16

sms-slinger-update

Updated source to the Sega Master System emulator found at codeslinger.co.uk
C++
2
star
17

RoboMower

Programmable lawn mowing fun!
C++
2
star
18

RS232_Wrap

Wraps OS native functions on Windows and Linux into a single cross platform C++ class for maintaining RS232 connections
C++
1
star
19

xyDocs

doxygen generated API docs for xygine
HTML
1
star
20

sfwaveform

SFML based audio file player which also renders a waveform
C++
1
star
21

AVRpp

small selection of 8-bit AVR utilities written in C++
C++
1
star
22

VideoTexture

Renders an MPEG1 video to an SFML Texture using the pl_mpeg library
C
1
star