Crossterm plugin for the bevy game engine

Overview

bevy_crossterm

What is bevy_crossterm?

bevy_crossterm is a Bevy plugin that uses crossterm as a renderer. It provides custom components and events which allow users to develop games for the terminal.

Table of Contents

Features

  • Sprites and styles with colors and attributes
    • Up to 24-bit color (depends on what the host terminal supports)
  • Incremental drawing: Only draw on the screen when something has changed
  • Transparency: Sprites can have holes so any sprites underneath will not be covered
  • Position, show, and hide the cursor
  • Set window title
  • Plugs into Bevy's asset system so sprites and styles can be loaded from disk and also hot reloaded

Demo GIF

demo

Getting Started

See the examples for runnable code and detailed comments.

[dependencies]
bevy = { version = "0.4", default-features = false }
bevy_crossterm = "0.4.0"
use bevy::prelude::*;
use bevy_crossterm::prelude::*;

pub fn main() {
    let mut settings = CrosstermWindowSettings::default();
    settings.set_title("Hello, World!");

    App::build()
        // Add our window settings
        .add_resource(settings)
        // Add the DefaultPlugins before the CrosstermPlugin. The crossterm plugin needs bevy's asset server, and if it's
        // not available you'll trigger an assert
        .add_plugins(DefaultPlugins)
        .add_plugin(CrosstermPlugin)
        .add_startup_system(startup_system.system())
        .run();
}

fn startup_system(
    commands: &mut Commands,
    mut sprites: ResMut>,
    mut stylemaps: ResMut>,
) {
    commands
        .spawn(SpriteBundle {
            sprite: sprites.add(Sprite::new("Hello, world!")),
            stylemap: stylemaps.add(StyleMap::default()),
            ..Default::default()
        });
}

Press Control-c to exit at any time.

Comments
  • fix failing to compile because of old broccoli

    fix failing to compile because of old broccoli

    When compiling the example from bevy_crossterm using rustc 1.51.0-nightly (a62a76047 2021-01-13) I got the following errors:

    error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
      --> /home/odd/.cargo/registry/src/github.com-1ecc6299db9ec823/broccoli-0.7.5/src/tree/container/inner.rs:69:73
       |
    69 |     let inner: compt::dfs_order::CompleteTreeContainer<NodePtr<T>, _> = inner.inner.inner.convert();
       |                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
       |
       = note: consult the function's documentation for information on how to avoid undefined behavior
    
    error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
      --> /home/odd/.cargo/registry/src/github.com-1ecc6299db9ec823/broccoli-0.7.5/src/tree/container/inner.rs:83:73
       |
    83 |     let inner: compt::dfs_order::CompleteTreeContainer<NodePtr<T>, _> = inner.inner.inner.convert();
       |                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
       |
       = note: consult the function's documentation for information on how to avoid undefined behavior
    
    error: aborting due to 2 previous errors
    
    For more information about this error, try `rustc --explain E0133`.
    error: could not compile `broccoli`
    

    Changing broccoli from version 0.7 to 0.20 fixed this.

    opened by ghost 2
  • Updated for bevy 0.5

    Updated for bevy 0.5

    Primarily updates to be compatible with bevy 0.5, but also:

    • Updates for IDE file ignores
    • Added a Makefile for development workflow convenience
    • Added a .rustfmt file and ran rustfmt
    • Bumped bevy_crossterm version to 0.5
    • Migrated package uses from within the code up to the top of the code for visibility
    • Used clippy suggestions
    • Migrated lib.rs structures into their own files

    Two logic changes that I think are relevant here.

    1. The changes within bevy-0.5 for pipeline stages allows for all of the stages to be executed within a single frame. Previously, we expected only one stage to be executed within a frame. The consequence is that it's less clear how state transitions actually run and also how to handle capturing input from the user. The API appears to have the right pieces, but the execution is no longer simple/intuitive.

    2. Because of the changes, we now explicitly update the keys data within the user input handler and we also initiate a cleanup within the same code space because it appears that the on_exit method is actually completely broken for state transitions.

    opened by brianbruggeman 0
  • Updated for bevy-0.5

    Updated for bevy-0.5

    Primarily updates to be compatible with bevy 0.5, but also:

    • Updates for IDE file ignores
    • Added a Makefile for development workflow convenience
    • Added a .rustfmt file and ran rustfmt
    • Bumped bevy_crossterm version to 0.5
    • Migrated package uses from within the code up to the top of the code for visibility
    • Used clippy suggestions
    • Migrated lib.rs structures into their own files

    Two logic changes that I think are relevant here.

    1. The changes within bevy-0.5 for pipeline stages allows for all of the stages to be executed within a single frame. Previously, we expected only one stage to be executed within a frame. The consequence is that it's less clear how state transitions actually run and also how to handle capturing input from the user. The API appears to have the right pieces, but the execution is no longer simple/intuitive.

    2. Because of the changes, we now explicitly update the keys data within the user input handler and we also initiate a cleanup within the same code space because it appears that the on_exit method is actually completely broken for state transitions. I have let the on_exit methods in there mostly because I think they should work. However, I've commented them out because they do not actually appear to run as expected.

    Fixes #7

    opened by brianbruggeman 0
  • Updated to work with bevy 0.5, Help wanted

    Updated to work with bevy 0.5, Help wanted

    Wanted to use this with bevy 0.5, so i updated it into a state that at least allows compiling. Gonna need help fixing the examples and cleaning up my code.

    opened by Nukeuler123 7
  • Propagate Parent Positions to children

    Propagate Parent Positions to children

    It would be nice to allow parent entities to have a Postition that is then propagated to the children (and so on recursively). One could then easily group and move entities together, instead of separately.

    enhancement 
    opened by octotep 1
  • Improve calulation_entities_to_redraw system

    Improve calulation_entities_to_redraw system

    The asset change detection is rough. We have to loop through all asset added/changed events, then loop through ALL entities to see which ones have assets that need to be changed. Not very graceful. There are a few improvements to be made here:

    • [ ] Cache which assets are assigned to which entities in a multimap (handleid -> Vec) to avoid needing to loop through all entities to find which ones have assets that changed that frame.
    • [ ] After that multimap exists, add an early out if we see 1) no assets we care about changed, 2) no entities changed, and 3) no new entities were added. This will do less work each frame where nothing changes, which will be nice
    enhancement 
    opened by octotep 6
Owner
null
A Client/Server game networking plugin using QUIC, for the Bevy game engine.

Bevy Quinnet A Client/Server game networking plugin using QUIC, for the Bevy game engine. Bevy Quinnet QUIC as a game networking protocol Features Roa

Gilles Henaux 65 Feb 20, 2023
Minecraft-esque voxel engine prototype made with the bevy game engine. Pending bevy 0.6 release to undergo a full rewrite.

vx_bevy A voxel engine prototype made using the Bevy game engine. Goals and features Very basic worldgen Animated chunk loading (ala cube world) Optim

Lucas Arriesse 125 Dec 31, 2022
Inspector plugin for the bevy game engine

bevy-inspector-egui This crate provides the ability to annotate structs with a #[derive(Inspectable)], which opens a debug interface using egui where

Jakob Hellermann 517 Dec 31, 2022
Hanabi — a particle system plugin for the Bevy game engine.

Hanabi — a particle system plugin for the Bevy game engine

Jerome Humbert 256 Dec 30, 2022
Tweening animation plugin for the Bevy game engine.

?? Bevy Tweening Tweening animation plugin for the Bevy game engine. Features Animate any field of any component or asset, including custom ones. Run

Jerome Humbert 135 Dec 23, 2022
A plugin to enable random number generation for the Bevy game engine.

bevy_turborand A plugin to enable random number generation for the Bevy game engine, built upon turborand. Implements ideas from Bevy's Deterministic

Gonçalo Rica Pais da Silva 15 Dec 23, 2022
A spectator camera plugin for the Bevy game engine

bevy_spectator A spectator camera plugin for the Bevy game engine. Controls Action Key Forward W Left A Backward S Right D Up Space Down LControl Alt.

Jonah Henriksson 5 Jan 2, 2023
A general-purpose transfom interpolation plugin for fixed timesteps for the Bevy game engine.

bevy_transform_interpolation A general-purpose Transform interpolation plugin for fixed timesteps for the Bevy game engine. What Is This For? A lot of

Joona Aalto 22 Oct 22, 2024
2d Endless Runner Game made with Bevy Game Engine

Cute-runner A 2d Endless Runner Game made with Bevy Game Engine. Table of contents Project Infos Usage Screenshots Disclaimer Project Infos Date: Sept

JoaoMarinho 2 Jul 15, 2022
A game of snake written in Rust using the Bevy game engine, targeting WebGL2

Snake using the Bevy Game Engine Prerequisites cargo install cargo-make Build and serve WASM version Set your local ip address in Makefile.toml (loca

Michael Dorst 0 Dec 26, 2021
A game made in one week for the Bevy engine's first game jam

¿Quien es el MechaBurro? An entry for the first Bevy game jam following the theme of "Unfair Advantage." It was made in one week using the wonderful B

mike 20 Dec 23, 2022
A Bevy Engine plugin for making 2D paths, smooth animations with Bezier curves

bevy_pen_tool A Bevy Engine plugin for making 2D paths and smooth animations with Bezier curves TODO: Mesh-making functionality for building 2D shapes

Eli 36 Dec 22, 2022
Bevy engine + miniquad render plugin

Bevy engine + miniquad renderer This is a plugin for Bevy engine that replaces default windowing and rendering plugins with miniquad based one. Usage

Tomasz Sterna 31 Dec 9, 2022
A Bevy plugin to use Kira for game audio

Bevy Kira audio This bevy plugin is intended to try integrating Kira into Bevy. The end goal would be to replace or update bevy_audio, if Kira turns o

Niklas Eicker 172 Jan 5, 2023
Basic first-person fly camera for the Bevy game engine

bevy_flycam A basic first-person fly camera for Bevy 0.4 Controls WASD to move horizontally SPACE to ascend LSHIFT to descend ESC to grab/release curs

Spencer Burris 85 Dec 23, 2022
Concise Reference Book for the Bevy Game Engine

Unofficial Bevy Cheat Book Click here to read the book! Concise reference to programming in the Bevy game engine. Covers useful syntax, features, prog

null 947 Jan 8, 2023
Proof-of-concept of getting OpenXR rendering support for Bevy game engine using gfx-rs abstractions

Introduction Proof-of-concept of getting OpenXR rendering support for Bevy game engine using gfx-rs abstractions. (hand interaction with boxes missing

Mika 52 Nov 14, 2022
A physics lib for the bevy game engine based on physme

physimple Physimple aims to be the simplest(and capable) physics engine(currently for bevy) WARNING Beware for breaking changes with each update for n

null 24 Oct 28, 2022
An immediate mode 2D drawing API for Bevy game engine

Bevy Canvas API prototype An unofficial immediate mode 2D drawing API for Bevy game engine. Check the documentation or the examples to know how to use

Federico Rinaldi 20 Apr 21, 2022