-
Notifications
You must be signed in to change notification settings - Fork 199
/
ldtk.rs
46 lines (40 loc) · 1.6 KB
/
ldtk.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! This example is capable of spawning tilemaps from [LDtk](https://ldtk.io) files.
//!
//! It can load the AutoTile and Tile layers of simple LDtk levels.
//! However, it does have limitations.
//! Some edge cases around tileset definitions and layer definitions haven't been considered here.
//! Furthermore, since this example is primarily concerned with the tilemap functionality,
//! there's no solution built in for Entity or Intgrid layers.
//!
//! For a more comprehensive LDtk solution, consider [bevy_ecs_ldtk](https://github.com/Trouv/bevy_ecs_ldtk), which uses bevy_ecs_tilemap internally.
use bevy::prelude::*;
use bevy_ecs_tilemap::*;
mod helpers;
fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(Camera2dBundle::default());
let handle: Handle<helpers::ldtk::LdtkMap> = asset_server.load("map.ldtk");
commands.spawn(helpers::ldtk::LdtkMapBundle {
ldtk_map: handle,
transform: Transform::from_xyz(0.0, 0.0, 0.0),
..Default::default()
});
}
fn main() {
App::new()
.add_plugins(
DefaultPlugins
.set(WindowPlugin {
primary_window: Some(Window {
title: String::from("LDTK Example"),
..Default::default()
}),
..default()
})
.set(ImagePlugin::default_nearest()),
)
.add_plugins(TilemapPlugin)
.add_plugins(helpers::ldtk::LdtkPlugin)
.add_systems(Startup, startup)
.add_systems(Update, helpers::camera::movement)
.run();
}