Skip to content

Commit

Permalink
Initializing a new bevy project
Browse files Browse the repository at this point in the history
Initialize a new binary crate

```shell
cargo init boxes
```

Add bevy as a dependency using cargo-edit.

```shell
cargo add bevy
```

Bring the bevy prelude into scope in `src/main.rs`

```rust
use bevy::prelude::*;
```

A prelude is a common term for "things the crate author thinks you'll need most of the time when using their crate". Instead of manually bringing everything we want into scope using it's own module path, which can get tiring, we can bring everything from the prelude into scope using `*`. Since a prelude is usually only re-exporting functions from the rest of the crate, this gives us easier access to what we would've needed anyway.

Bevy games are called "App"s and are constructed using a builder pattern. In this case we use [`App::build()`](https://docs.rs/bevy/0.5.0/bevy/app/struct.App.html) to kick off the builder, then we add the `DefaultPlugins` from the bevy prelude, and finally `.run()` executes the application.

```rust
fn main() {
    App::build().add_plugins(DefaultPlugins).run()
}
```

Bevy by itself doesn't do much because it allows us to add all of the functionality we want via plugins. These plugins can come from the project itself or third party crates.

`DefaultPlugins` is a group of plugins that handle core bevy functionality such as enabling the window holding our game to show, handling user keyboard input, or diagnostics and logging.

You could imagine scenarios where we wouldn't want to render a window, such as if we were running bevy on a server in a multiplayer game.

Running this program shows us a window with the title `bevy` and no content. Seeing this window means everything is set up appropriately.
  • Loading branch information
ChristopherBiscardi committed Jun 30, 2021
0 parents commit 35f653b
Show file tree
Hide file tree
Showing 4 changed files with 3,461 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
/target

0 comments on commit 35f653b

Please sign in to comment.