Crates.io | ldtk_map |
lib.rs | ldtk_map |
version | 0.3.1 |
source | src |
created_at | 2023-08-14 00:28:18.041919 |
updated_at | 2023-11-19 04:50:12.781427 |
description | A crate for reading ldtk maps for usage in games. |
homepage | |
repository | https://github.com/benlloyd50/ldtk_map/ |
max_upload_size | |
id | 943718 |
size | 33,034 |
A crate for reading the LDtk v1.3.4 maps into a more user-friendly (read opinionated) data structure for usage in game.
LDtk maps contain a lot of data that the developer is probably not going to need to use. This crate implements the structs for the LDtk map but abstracts them behind a DesignMap. The DesignMap contains only a small amount of that data but it is what I found necessary when building my game. In turn the goal of this crate is providing this simple interface when working with this files. It should function as a good crate for beginners wanting to make games in rust. However, this crate is not trying to give you access to every field on your LDtk file. Luckily, some other fine devs made crates that might suit your use case better:
ldtk Note: mind the license
Cargo.toml
ldtk_map = { version = "0.3.1" }
** or in your cmd line **
cargo add ldtk_map
The public facing of DesignMap
and child structs aims to be as simple as possible:
use ldtk_map::prelude::*;
fn main() {
// Replace with your ldtk file!
let my_design = DesignMap::load("../tests/testmaps/two_tileatlases.ldtk");
// Get some info about your tile in Level_0 at (0, 0)
my_design.levels().get("Level_0").unwrap().level()[0].atlas_index();
// Use in your game by reading to your own map data struct
convert_to_games_map(&my_design);
}
The map must be formatted using the guidelines or else it will not be loaded into DesignMap
properly.
width
, height
, grid_size
, and tileset_name
.Everyone is more than welcome to submit feature requests and bug fixes. I will comb through these as frequently as possible and try to handle them accordingly.