Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/LittleB0xes/LDtkBridge
A bridge between LDtk and DragonRuby
https://github.com/LittleB0xes/LDtkBridge
dragonruby game-development gamedev gamedev-library ldtk
Last synced: about 1 month ago
JSON representation
A bridge between LDtk and DragonRuby
- Host: GitHub
- URL: https://github.com/LittleB0xes/LDtkBridge
- Owner: LittleB0xes
- License: mit
- Created: 2021-05-23T05:36:05.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-10T16:18:35.000Z (about 1 month ago)
- Last Synced: 2024-11-10T17:25:27.663Z (about 1 month ago)
- Topics: dragonruby, game-development, gamedev, gamedev-library, ldtk
- Language: Ruby
- Homepage:
- Size: 107 KB
- Stars: 19
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-dragonruby - LDtkBridge - A bridge between LDtk (level editor) and DragonRuby (Libraries, Frameworks and Wrappers)
README
# LDtkBridge
A bridge between LDtk and DragonRuby⚠️ construction in progress ⚠️
Documentation in progress too !
## Usage
### LDtk project init
First you need to init your map```ruby
my_world = LDtk.create_world('path_to_your_file', 'your_ldtk_file.ldtk')
```
my_world is a `Hash` and has this structure :
```ruby
{
folder: 'path_to_your_file/',
levels: {}, # Hash with all levels
definitions: {} # some useful information about tilesets
}
```### Loading Levels and Layers
#### Level
If in your LDtk file, your level is named "Level_1" in LDtk, LDtkBridge converts it to a symbol `:Level_1`.This level can be load like this
```ruby
my_level = LDtk.level(my_world, :Level_1)
```Each level is a hash with keys :
```ruby
{
identifier: # Symbol name of the level
uid: # Integer Unique integer identifier
iid: # String Unique instance identifier
px_hei: # Integer height of the level in px,
px_wid: # Integer width of the level in px,
world_x: # Integer x position of the level in the world in px,
world_y: # Integer y position of the level in the world in px,
layers: # Hash hash of layer with layer identifier as key
field: # Array array of field hash`
}
```#### Layers
In the same way, you can load a layer named "Ground" in "Level_1" with```ruby
my_layer = LDtk.layer(my_world, :Level_1, :Ground)
```
Each layer is a hash with keys
```ruby
{
cell_width: # Integer width in cells
cell_height: # Integer height in cells
grid_size: # Integer cell size in px
identifier # Symbol name of the layer
type: # Symbol Layer type
# (possible values: :IntGrid,:Entities, :Tiles or :AutoLayer)
iid: # String Unique instance identifier
tileset_def_uid: # Integer definition id of the layer's tileset
tileset_rel_path: # String relative path of tileset
grid_tiles # Array array of tiles's hash (dr friendly)
entities # Array array of entity's hash
int_grid # Array array of int in 'dr-friendly' orientation
}
```### Tile Layer
When the layer is a tiles layer (id `type: :Tiles), `grid_tiles` key link to an array of tile.
LDtkBridge make DR friendly tiles (plus some useful fields). So tiles have this format :
```ruby
{
x:
y:
w:
h:
source_x:
source_y:
source_w:
source_h:
flip_horizontally:
flip_vertically:tile_id:
enum_tags
}
```
### Entities Layer### Int Grid Layer