Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jakubtomsu/odin-ldtk
Odin loader for LDtk files. LDtk is a modern 2D level editor from the creator of Dead Cells, with a strong focus on user-friendliness.
https://github.com/jakubtomsu/odin-ldtk
gamedev ldtk odin odin-lang odin-lib
Last synced: 18 days ago
JSON representation
Odin loader for LDtk files. LDtk is a modern 2D level editor from the creator of Dead Cells, with a strong focus on user-friendliness.
- Host: GitHub
- URL: https://github.com/jakubtomsu/odin-ldtk
- Owner: jakubtomsu
- License: mit
- Created: 2023-07-07T16:40:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-24T19:48:58.000Z (8 months ago)
- Last Synced: 2024-04-24T21:07:00.313Z (8 months ago)
- Topics: gamedev, ldtk, odin, odin-lang, odin-lib
- Language: Odin
- Homepage: https://ldtk.io/
- Size: 106 KB
- Stars: 18
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-odin - LDtk utility - ldtk/blob/main/LICENSE) | Gamedev, Assets, Tools (Libraries / Formats)
README
# odin-ldtk
Loader for [LDtk](https://ldtk.io/) files. Uses Odin's `core:json` to unmarshal data into structs.> LDtk is a modern 2D level editor from the creator of Dead Cells,
with a strong focus on user-friendliness.Current version: `1.3.3`
The data definitions were generated with [JSON scheme and QuickType](https://ldtk.io/docs/game-dev/loading/?menu=1#2-the-quicktype-way) for rust and then manually edited.
## How to use
Put the `ldtk.odin` file to a `ldtk` folder somewhere in your project. Then you can just do this (the path might be different):
```odin
import "../ldtk"
```
And then:
```odin
if project, ok := ldtk.load_from_file("foo.ldtk", context.temp_allocator).?; ok {
for biome in project.defs.biomes {
// use biomes ...
}for level in proj.levels {
for layer in level.layers {
switch layer.type {
case .IntGrid:
case .Entities:
case .Tiles:
case .AutoLayer:
}
}
}// ...
}
```
Note: `value` in `Field_Instance` can be a different type depending on the data.
For this reason the type is `json.Value`, which works like `any` in this case, and you can do whatever you want with it.## Example
There is an example of a basic 2d platformer in the [example](example/) folder. It uses raylib for the tilemap rendering. The initial implementation is by @Smilex.Hot to use:
```
cd example
odin run .
```## Contributing
Contributions are welcome!