// This example shows the basic usage of the plugin to load a Tiled world.
use bevy::prelude::*;
use bevy_ecs_tiled::prelude::*;
mod helper;
fn main() {
App::new()
// Bevy default plugins: prevent blur effect by changing default sampling
.add_plugins(DefaultPlugins.build().set(ImagePlugin::default_nearest()))
// Add bevy_ecs_tiled plugin: bevy_ecs_tilemap::TilemapPlugin will
// be automatically added as well if it's not already done
.add_plugins(TiledPlugin::default())
// Examples helper plugins, such as the logic to pan and zoom the camera
// This should not be used directly in your game (but you can always have a look)
.add_plugins(helper::HelperPlugin)
// Add our systems and run the app!
.add_systems(Startup, startup)
.run();
}
fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
// Spawn a 2D camera (required by Bevy)
commands.spawn(Camera2d);
// Load a world then spawn it
commands.spawn((
// Only the [`TiledWorld`] component is actually required to spawn a world
TiledWorld(asset_server.load("worlds/orthogonal.world")),
// But you can add extra components to change the defaults settings and how
// your world is actually displayed
TilemapAnchor::Center,
));
}