Git Product home page Git Product logo

bevy_tmx's Introduction

bevy_tmx

Documentation Crates.io License

bevy_tmx is a plugin for the bevy game engine that allows you to read .tmx files from the tiled map editor as scenes. The plugin can be configured so that you can add more of your own components to the entities of the scene.

Currently, the tile maps being rendered are fairly simple, they are loaded as simple sprite entities, one per layer and sprite sheet.

Features

  • All tile layout modes supported by tiled:
    • Orthogonal
    • Isometric staggered and non-staggered
    • Hexagonal staggered
  • Object layers with support for custom object processing
  • Image layers with support for custom image layer processing
  • Parallax rendering

Todo

  • Infinite map support
  • All render orders other than RightDown

Overview

Using bevy_tmx is supposed to be really simple, just add the TmxPlugin to your App and load a scene. If you need to add custom functionality to the entities loaded from the .tmx file, you can customize the TmxLoader to do so during load time.

Example

use bevy::prelude::*;
use bevy::window::WindowMode;

use bevy_tmx::TmxPlugin;

struct PlayerComponent;

fn main() {
    App::build()
        .insert_resource(WindowDescriptor {
            title: "Ortho".to_string(),
            width: 1024.,
            height: 720.,
            vsync: false,
            resizable: true,
            mode: WindowMode::Windowed,
            ..Default::default()
        })
        .add_plugins(DefaultPlugins)
        .add_plugin(TmxPlugin::default()
            // Note that in tiled, the y axis points down, but in bevy it points up. The default scale is (1.0, -1.0).
            .scale(Vec2::new(3.0, -3.0))
            // This is the place to add more functionality to your objects
            .visit_objects(|object, entity| {
                if object.ty == "player" {
                    entity.insert(PlayerComponent);
                }
            })
        )
        .add_startup_system(spawn_scene.system())
        .run()
}

fn spawn_scene(mut commands: Commands, asset_server: Res<AssetServer>) {
    commands.spawn_scene(asset_server.load("ortho-map.tmx"));
    commands.spawn().insert_bundle(OrthographicCameraBundle {
        transform: Transform::from_xyz(600.0, -600.0, 50.0),
        ..OrthographicCameraBundle::new_2d()
    });
}

bevy_tmx's People

Contributors

kurble avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.