diff --git a/README.md b/README.md index f66b844c59..12ca47838d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ## What is Bevy? -Bevy is a modular game engine built in Rust, with a focus on developer productivity and performance. +Bevy is an open-source modular game engine built in Rust, with a focus on developer productivity and performance. ## WARNING diff --git a/bevy_app/src/app_builder.rs b/bevy_app/src/app_builder.rs index 73bfc667bc..586499efae 100644 --- a/bevy_app/src/app_builder.rs +++ b/bevy_app/src/app_builder.rs @@ -4,7 +4,7 @@ use crate::{ stage, App, Events, }; -use legion::prelude::{Resources, Runnable, Schedulable, Universe, World}; +use legion::prelude::{Resources, Runnable, Schedulable, Universe, World, SystemBuilder, CommandBuffer}; static APP_MISSING_MESSAGE: &str = "This AppBuilder no longer has an App. Check to see if you already called run(). A call to app_builder.run() consumes the AppBuilder's App."; @@ -121,6 +121,15 @@ impl AppBuilder { self.add_system_to_stage(stage::UPDATE, system) } + pub fn add_system_fn(&mut self, name: &'static str, system: impl Fn(&mut CommandBuffer) + Send + Sync + 'static) -> &mut Self { + let built_system = SystemBuilder::new(name) + .build(move |command_buffer, _, _, _| { + system(command_buffer); + }); + self.add_system_to_stage(stage::UPDATE, built_system); + self + } + pub fn add_startup_system_to_stage( &mut self, stage_name: &str, diff --git a/examples/hello_world.rs b/examples/hello_world.rs new file mode 100644 index 0000000000..6f4df6ad16 --- /dev/null +++ b/examples/hello_world.rs @@ -0,0 +1,8 @@ +use bevy::prelude::*; + +fn main() { + App::build() + .add_default_plugins() + .add_system_fn("hello", |_| println!("hello world!")) + .run(); +} diff --git a/src/lib.rs b/src/lib.rs index 9f54c761ec..1e51dce156 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,13 +1,20 @@ -//! Bevy is a modular game engine built in Rust, with a focus on developer productivity and performance. -//! -//! It has the following design goals: -//! * Provide a first class user-experience for both 2D and 3D games -//! * Easy for newbies to pick up, but infinitely flexible for power users -//! * Fast iterative compile times. Ideally less than 1 second for small to medium sized projects -//! * Data-first game development using ECS (Entity Component Systems) -//! * High performance and parallel architecture -//! * Use the latest and greatest rendering technologies and techniques -//! +//! Bevy is an open-source modular game engine built in Rust, with a focus on developer productivity and performance. +//! +//! Check out the [Bevy website](https://bevyengine.org) for more information, read the +//! [Bevy Book](https://bevyengine.org/learn/book/introduction) for a step-by-step guide, and [engage with our +//! community](https://bevyengine.org/community/) if you have any questions or ideas! +//! +//! ``` +//!use bevy::prelude::*; +//! +//!fn main() { +//! App::build() +//! .add_default_plugins() +//! .add_system_fn("hello", |_| println!("hello world!")) +//! .run(); +//!} +//! ``` +//! //! The "bevy" crate is just a container crate that makes it easier to consume Bevy components. //! The defaults provide a "full" engine experience, but you can easily enable / disable features //! in your project's Cargo.toml to meet your specific needs. See Bevy's Cargo.toml for a full list of features available.