Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Ragath/TiledLib.Net
Cross-platform Tiled map parsing utilities.
https://github.com/Ragath/TiledLib.Net
content-management monogame parser parsing pipeline tiled tiled-parser tilemap
Last synced: 9 days ago
JSON representation
Cross-platform Tiled map parsing utilities.
- Host: GitHub
- URL: https://github.com/Ragath/TiledLib.Net
- Owner: Ragath
- License: mit
- Created: 2017-07-27T22:17:44.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-18T10:45:31.000Z (3 months ago)
- Last Synced: 2024-09-18T11:57:31.593Z (about 2 months ago)
- Topics: content-management, monogame, parser, parsing, pipeline, tiled, tiled-parser, tilemap
- Language: C#
- Size: 348 KB
- Stars: 25
- Watchers: 2
- Forks: 8
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-monogame - TiledLib.Net - ![GitHub stars](https://img.shields.io/github/stars/Ragath/TiledLib.Net.svg) - Cross-platform Tiled map parsing utilities. (Tiles)
README
# TiledLib.Net
[![.NET](https://github.com/Ragath/TiledLib.Net/actions/workflows/dotnet.yml/badge.svg)](https://github.com/Ragath/TiledLib.Net/actions/workflows/dotnet.yml)
Cross-platform Tiled map parsing utilities.## Nugets
[![](Docs/Images/nuget.png) TiledLib](https://www.nuget.org/packages/TiledLib/) - Core library, everything you need to read Tiled maps/tilesets.
[![](Docs/Images/nuget.png) TiledLib.Pipeline](https://www.nuget.org/packages/TiledLib.Pipeline/) - MonoGame content pipeline extension, provides a ContentImporter for Tiled maps.
If you add a ContentProcessor, you will be able to map the output of the supplied importer to custom classes tailored specifically for your game.## Basic usecase
```csharp
using (var stream = File.OpenRead(filename))
{
var map = Map.FromStream(stream, ts => File.OpenRead(Path.Combine(Path.GetDirectoryName(filename), ts.Source)));foreach (var layer in map.Layers.OfType())
{
for (int y = 0, i = 0; y < layer.Height; y++)
for (int x = 0; x < layer.Width; x++, i++)
{
var gid = layer.data[i];
if (gid == 0)
continue;var tileset = map.Tilesets.Single(ts => gid >= ts.FirstGid && ts.FirstGid + ts.TileCount > gid);
var tile = tileset[gid];// Do stuff with the tile.
}
}
}
```