#ldtk #who #thin #people #freely #file #level-design

ldtk2

A thin crate for people who just want to use ldtk files freely

16 releases

0.8.0 Mar 11, 2024
0.7.0 Apr 25, 2022
0.6.0 Mar 30, 2022
0.5.1 Aug 26, 2021
0.2.1 Feb 16, 2021

#219 in Game dev

Download history 3/week @ 2024-02-21 4/week @ 2024-02-28 201/week @ 2024-03-06 35/week @ 2024-03-13 21/week @ 2024-03-27 43/week @ 2024-04-03

118 downloads per month

Apache-2.0

60KB
773 lines

Crates.io Documentation License Workflow Status

ldtk2

A thin crate for people who just want to use ldtk files freely.

Why did I create this nonsense?

  • LDtk-rs uses code generation, it does not get autocomplete support from rust-analyzer. Also, there are special license restrictions on using that crate.
  • ldtk_rust uses .except() inside the crate, you can't handle errors.

Supported LDtk file versions

^1.5

Usage

cargo add ldtk2
use std::{error::Error, path::Path, convert::TryInto};
use ldtk2::Ldtk;

fn main() -> Result<(), Box<dyn Error>> {

  let map = Ldtk::from_path("tests/example.ldtk")?;
  // or
  let map: Ldtk = Path::new("tests/example.ldtk").try_into()?;
  // or
  let map = Ldtk::from_str(include_str!("../tests/example.ldtk"))?;
  // or
  let map: Ldtk = include_str!("../tests/example.ldtk").try_into()?;

  Ok(())
}

Dependencies

~0.6–1.4MB
~32K SLoC