Convert Figma logo to code with AI

bevyengine logobevy

A refreshingly simple data-driven game engine built in Rust

35,058
3,441
35,058
2,278

Top Related Projects

90,206

Godot Engine – Multi-platform 2D and 3D game engine

Data-oriented and data-driven game engine written in Rust

4,212

Rust library to create a Good Game Easily

4,611

A modular game engine written in Rust

12,131

A cross-platform, safe, pure-Rust graphics API.

Quick Overview

Bevy is a data-driven game engine built in Rust, focusing on simplicity and modularity. It aims to provide a complete solution for game development, including rendering, audio, and asset management, while maintaining a user-friendly API and excellent performance.

Pros

  • Fast compilation times and runtime performance due to Rust's efficiency
  • Modular architecture allowing easy customization and extension
  • Strong community support and active development
  • Cross-platform compatibility (Windows, macOS, Linux, Web)

Cons

  • Relatively new project, still in active development (may have breaking changes)
  • Learning curve for developers new to Rust or ECS (Entity Component System) architecture
  • Limited documentation compared to more established game engines
  • Smaller ecosystem of third-party plugins and tools compared to Unity or Unreal

Code Examples

  1. Creating a simple 2D sprite:
use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_startup_system(setup)
        .run();
}

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
    commands.spawn(Camera2dBundle::default());
    commands.spawn(SpriteBundle {
        texture: asset_server.load("sprite.png"),
        ..default()
    });
}
  1. Adding a simple movement system:
use bevy::prelude::*;

#[derive(Component)]
struct Player;

fn move_player(
    time: Res<Time>,
    keyboard_input: Res<Input<KeyCode>>,
    mut query: Query<&mut Transform, With<Player>>,
) {
    for mut transform in query.iter_mut() {
        let mut direction = Vec3::ZERO;
        if keyboard_input.pressed(KeyCode::Left) {
            direction.x -= 1.0;
        }
        if keyboard_input.pressed(KeyCode::Right) {
            direction.x += 1.0;
        }
        transform.translation += direction * 200.0 * time.delta_seconds();
    }
}
  1. Creating a simple UI text element:
use bevy::prelude::*;

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
    commands.spawn(Camera2dBundle::default());
    commands.spawn(TextBundle::from_section(
        "Hello, Bevy!",
        TextStyle {
            font: asset_server.load("fonts/FiraSans-Bold.ttf"),
            font_size: 60.0,
            color: Color::WHITE,
        },
    ));
}

Getting Started

To start using Bevy, add it to your Cargo.toml:

[dependencies]
bevy = "0.10.0"

Then, create a new Rust file with a basic Bevy app structure:

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_startup_system(setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2dBundle::default());
    // Add your game setup logic here
}

Run your project with cargo run to see a blank window. Start adding systems and components to build your game!

Competitor Comparisons

90,206

Godot Engine – Multi-platform 2D and 3D game engine

Pros of Godot

  • More mature and feature-rich game engine with a longer development history
  • Comprehensive built-in editor with visual scripting capabilities
  • Larger community and ecosystem with extensive documentation and tutorials

Cons of Godot

  • Steeper learning curve due to its extensive feature set
  • Larger codebase and potentially slower compilation times
  • Less flexibility for low-level engine customization

Code Comparison

Godot (GDScript):

extends Sprite2D

func _ready():
    position = Vector2(100, 100)
    scale = Vector2(2, 2)

Bevy (Rust):

use bevy::prelude::*;

fn setup(mut commands: Commands) {
    commands.spawn(SpriteBundle {
        transform: Transform::from_xyz(100.0, 100.0, 0.0).with_scale(Vec3::new(2.0, 2.0, 1.0)),
        ..default()
    });
}

Godot uses a more traditional object-oriented approach with its own scripting language, while Bevy leverages Rust's powerful type system and entity-component-system architecture for game development.

Data-oriented and data-driven game engine written in Rust

Pros of Amethyst

  • More mature and established project with a longer history
  • Extensive documentation and tutorials available
  • Strong focus on ECS (Entity Component System) architecture

Cons of Amethyst

  • Slower development pace and less frequent updates
  • Steeper learning curve for beginners
  • Less active community compared to Bevy

Code Comparison

Amethyst:

use amethyst::prelude::*;

struct MyState;

impl SimpleState for MyState {
    fn on_start(&mut self, _data: StateData<'_, GameData<'_, '_>>) {
        println!("Starting game!");
    }
}

Bevy:

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_startup_system(setup)
        .run();
}

fn setup(mut commands: Commands) {
    println!("Starting game!");
}

Both Amethyst and Bevy are Rust game engines, but Bevy has gained significant popularity due to its simpler API, faster compilation times, and more active development. Amethyst offers a more traditional ECS approach, while Bevy introduces a unique ECS implementation with a focus on ease of use and performance. Bevy's modular plugin system and hot reloading capabilities make it more appealing for rapid development, whereas Amethyst's mature codebase and extensive documentation may be preferred for larger, more complex projects.

4,212

Rust library to create a Good Game Easily

Pros of ggez

  • Simpler and more lightweight, making it easier to learn and use for beginners
  • Focuses on 2D game development, providing a more streamlined experience for 2D projects
  • Has been around longer, resulting in a more mature ecosystem and documentation

Cons of ggez

  • Limited to 2D game development, lacking support for 3D graphics
  • Smaller community and ecosystem compared to Bevy
  • Less frequent updates and slower development pace

Code Comparison

ggez example:

use ggez::{Context, ContextBuilder, GameResult};
use ggez::graphics::{self, Color};
use ggez::event::{self, EventHandler};

struct MainState {}

impl EventHandler for MainState {
    fn update(&mut self, _ctx: &mut Context) -> GameResult {
        Ok(())
    }

    fn draw(&mut self, ctx: &mut Context) -> GameResult {
        graphics::clear(ctx, Color::WHITE);
        graphics::present(ctx)?;
        Ok(())
    }
}

Bevy example:

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_startup_system(setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2dBundle::default());
}

Both examples show basic setup, but Bevy's ECS-based approach is more declarative and modular.

4,611

A modular game engine written in Rust

Pros of Piston

  • Longer development history, potentially more stable and mature
  • More flexible and modular architecture, allowing for greater customization
  • Larger ecosystem of extensions and plugins

Cons of Piston

  • Less active development and community engagement
  • Steeper learning curve due to its modular nature
  • Documentation may be less comprehensive and up-to-date

Code Comparison

Piston:

extern crate piston_window;
use piston_window::*;

fn main() {
    let mut window: PistonWindow = WindowSettings::new("Hello Piston!", [640, 480])
        .exit_on_esc(true).build().unwrap();
    while let Some(event) = window.next() {
        window.draw_2d(&event, |context, graphics, _| {
            clear([1.0; 4], graphics);
        });
    }
}

Bevy:

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2dBundle::default());
}

The code comparison shows that Bevy has a more declarative and entity-component-system (ECS) based approach, while Piston uses a more traditional game loop structure. Bevy's syntax is generally more concise and modern, reflecting its newer design philosophy.

12,131

A cross-platform, safe, pure-Rust graphics API.

Pros of wgpu

  • Lower-level graphics API, offering more fine-grained control
  • Cross-platform support for multiple graphics backends (Vulkan, Metal, D3D12, WebGPU)
  • Potentially better performance for complex rendering scenarios

Cons of wgpu

  • Steeper learning curve, requiring more graphics programming knowledge
  • Less built-in functionality for game development
  • Requires more boilerplate code for basic rendering tasks

Code Comparison

wgpu:

let mut encoder = device.create_command_encoder(&CommandEncoderDescriptor { label: None });
{
    let mut render_pass = encoder.begin_render_pass(&RenderPassDescriptor {
        color_attachments: &[RenderPassColorAttachment {
            view: &view,
            resolve_target: None,
            ops: Operations {
                load: LoadOp::Clear(Color::GREEN),
                store: true,
            },
        }],
        depth_stencil_attachment: None,
    });
}

Bevy:

fn setup(mut commands: Commands) {
    commands.spawn(Camera2dBundle::default());
    commands.spawn(SpriteBundle {
        sprite: Sprite {
            color: Color::rgb(0.25, 0.25, 0.75),
            custom_size: Some(Vec2::new(50.0, 50.0)),
            ..default()
        },
        ..default()
    });
}

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Bevy

License Crates.io Downloads Docs CI Discord

What is Bevy?

Bevy is a refreshingly simple data-driven game engine built in Rust. It is free and open-source forever!

WARNING

Bevy is still in the early stages of development. Important features are missing. Documentation is sparse. A new version of Bevy containing breaking changes to the API is released approximately once every 3 months. We provide migration guides, but we can't guarantee migrations will always be easy. Use only if you are willing to work in this environment.

MSRV: Bevy relies heavily on improvements in the Rust language and compiler. As a result, the Minimum Supported Rust Version (MSRV) is generally close to "the latest stable release" of Rust.

Design Goals

  • Capable: Offer a complete 2D and 3D feature set
  • Simple: Easy for newbies to pick up, but infinitely flexible for power users
  • Data Focused: Data-oriented architecture using the Entity Component System paradigm
  • Modular: Use only what you need. Replace what you don't like
  • Fast: App logic should run quickly, and when possible, in parallel
  • Productive: Changes should compile quickly ... waiting isn't fun

About

  • Features: A quick overview of Bevy's features.
  • News: A development blog that covers our progress, plans and shiny new features.

Docs

Community

Before contributing or participating in discussions with the community, you should familiarize yourself with our Code of Conduct.

  • Discord: Bevy's official discord server.
  • Reddit: Bevy's official subreddit.
  • GitHub Discussions: The best place for questions about Bevy, answered right here!
  • Bevy Assets: A collection of awesome Bevy projects, tools, plugins and learning materials.

Contributing

If you'd like to help build Bevy, check out the Contributor's Guide. For simple problems, feel free to open an issue or PR and tackle it yourself!

For more complex architecture decisions and experimental mad science, please open an RFC (Request For Comments) so we can brainstorm together effectively!

Getting Started

We recommend checking out the Quick Start Guide for a brief introduction.

Follow the Setup guide to ensure your development environment is set up correctly. Once set up, you can quickly try out the examples by cloning this repo and running the following commands:

# Switch to the correct version (latest release, default is main development branch)
git checkout latest
# Runs the "breakout" example
cargo run --example breakout

To draw a window with standard functionality enabled, use:

use bevy::prelude::*;

fn main(){
  App::new()
    .add_plugins(DefaultPlugins)
    .run();
}

Fast Compiles

Bevy can be built just fine using default configuration on stable Rust. However for really fast iterative compiles, you should enable the "fast compiles" setup by following the instructions here.

Bevy Cargo Features

This list outlines the different cargo features supported by Bevy. These allow you to customize the Bevy feature set for your use-case.

Thanks

Bevy is the result of the hard work of many people. A huge thanks to all Bevy contributors, the many open source projects that have come before us, the Rust gamedev ecosystem, and the many libraries we build on.

A huge thanks to Bevy's generous sponsors. Bevy will always be free and open source, but it isn't free to make. Please consider sponsoring our work if you like what we're building.

This project is tested with BrowserStack.

License

Bevy is free, open source and permissively licensed! Except where noted (below and/or in individual files), all code in this repository is dual-licensed under either:

at your option. This means you can select the license you prefer! This dual-licensing approach is the de-facto standard in the Rust ecosystem and there are very good reasons to include both.

Some of the engine's code carries additional copyright notices and license terms due to their external origins. These are generally BSD-like, but exact details vary by crate: If the README of a crate contains a 'License' header (or similar), the additional copyright notices and license terms applicable to that crate will be listed. The above licensing requirement still applies to contributions to those crates, and sections of those crates will carry those license terms. The license field of each crate will also reflect this. For example, bevy_mikktspace has code under the Zlib license (as well as a copyright notice when choosing the MIT license).

The assets included in this repository (for our examples) typically fall under different open licenses. These will not be included in your game (unless copied in by you), and they are not distributed in the published bevy crates. See CREDITS.md for the details of the licenses of those files.

Your contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.