Skip to content

Commit 01a304e

Browse files
committed
update changelog and tutorial for the Bevy 0.10 upgrade
1 parent f14e00d commit 01a304e

23 files changed

+147
-124
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
<!-- next-header -->
22
## [Unreleased] - ReleaseDate
33

4+
### Breaking changes
5+
6+
- `WindowDescriptor` has been renamed to `Window`
7+
- You must new add `#[derive(Resource)]` above your `GameState` struct.
8+
- It is no longer possible to use the unit type `()` instead of a `GameState` struct. Always create a `GameState` struct (it can be an empty struct with no fields).
9+
- The `Timer` now takes a `TimerMode` enum variant instead of a `bool`. Use `TimerMode::Once` for a timer that runs once, or `TimerMode::Repeating` for a repeating timer.
10+
11+
### Improved
12+
13+
- Update bevy from 0.8 to 0.10
14+
- Update bevy_prototype_lyon from 0.6 to 0.8
15+
- Update ron from 0.7 to 0.8
16+
- Fixed some inconsistent parameter names in examples
17+
18+
419
## [5.2.1] - 2022-11-15
520

621
### Improved

examples/mouse_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct GameState {}
1313
fn main() {
1414
let mut game = Game::new();
1515

16-
let race_car = game.add_sprite("Race Car", SpritePreset::RacingCarGreen);
16+
let race_car = game.add_sprite("Race Car", "sprite/racing/car_blue.png");
1717
race_car.translation = Vec2::new(0.0, 0.0);
1818
race_car.rotation = UP;
1919
race_car.scale = 1.0;

examples/window.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919
resizable: false,
2020
decorations: false,
2121
cursor,
22-
..Default::default() // for the rest of the options, see https://docs.rs/bevy/0.11.3/bevy/window/struct.Window.html
22+
..Default::default() // for the rest of the options, see https://docs.rs/bevy/0.10.1/bevy/index.html
2323
});
2424
let _ = game.add_text(
2525
"message",

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub mod prelude {
7979
DOWN, EAST, LEFT, NORTH, NORTH_EAST, NORTH_WEST, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, UP,
8080
WEST,
8181
};
82+
pub use bevy::ecs as bevy_ecs;
8283
pub use bevy::{
8384
self,
8485
prelude::{Resource, Time, Timer, TimerMode, Vec2},

tutorial/src/00-welcome.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
Rusty Engine is a simple, 2D game engine for those who are learning Rust. Create simple game prototypes using straightforward Rust code without needing to learning difficult game engine concepts! It works on macOS, Linux, and Windows. Rusty Engine is a simplification wrapper over [Bevy](https://bevyengine.org/), which I encourage you to use directly for more serious game engine needs.
44

5-
The following courses use Rusty Engine in their curriculum:
5+
The following courses currently use Rusty Engine in their curriculum:
6+
7+
- [Ultimate Rust 2: Intermediate Concepts](https://agileperception.com/ultimate_rust_2) (the sequel to [Ultimate Rust Crash Course](https://agileperception.com/ultimate_rust_crash_course))
68

7-
- [Ultimate Rust 2: Intermediate Concepts](https://www.udemy.com/course/ultimate-rust-2/?referralCode=8ED694EBE5637F954414) on Udemy (the sequel to [Ultimate Rust Crash Course](https://www.udemy.com/course/ultimate-rust-crash-course/?referralCode=AF30FAD8C6CCCC2C94F0))
8-
- [Rust in 3 Weeks](https://agileperception.com) conducted live on O'Reilly Online approximately once each quarter.
99

1010
# Tutorial
1111

tutorial/src/02-quick-start.md

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Quick Start Example
22

3-
- Create a new Rust project and add `rusty_engine` as a dependency (see the [Configuration](05-config.md) page for more details)
3+
- Create a new Rust project and run `cargo add rusty_engine` to add Rusty Engine as a dependency (see the [Configuration](05-config.md) page for more details). Your `Cargo.toml` file should end up with a line similar to this:
44
```toml
55
# In your [dependencies] section of Cargo.toml
66
rusty_engine = "5.2.1"
@@ -13,48 +13,44 @@ curl -L https://github.com/CleanCut/rusty_engine/archive/refs/heads/main.tar.gz
1313

1414
```rust,ignore
1515
// in src/main.rs
16-
use rusty_engine::prelude::*;
17-
18-
// Define a struct to hold custom data for your game (it can be a lot more complicated than this one!)
19-
struct GameState {
20-
health: i32,
21-
}
22-
23-
fn main() {
24-
// Create a game
25-
let mut game = Game::new();
26-
27-
// Set up your game. `Game` exposes all of the methods and fields of `Engine`
28-
let sprite = game.add_sprite("player", SpritePreset::RacingCarBlue);
29-
sprite.scale = 2.0;
30-
31-
game.audio_manager.play_music(MusicPreset::Classy8Bit, 1.0);
32-
33-
// Add one or more functions with logic for your game. When the game is run, the logic
34-
// functions will run in the order they were added.
35-
game.add_logic(game_logic);
36-
37-
// Run the game, with an initial state
38-
game.run(GameState { health: 100 });
39-
}
40-
41-
// Your game logic functions can be named anything, but the first parameter is always a
42-
// `&mut Engine`, and the second parameter is a mutable reference to your custom game
43-
// state struct (`&mut GameState` in this case). The function returns a `bool`.
44-
//
45-
// This function will be run once each frame.
46-
fn game_logic(engine: &mut Engine, game_state: &mut GameState) {
47-
// The `Engine` contains all sorts of built-in goodies.
48-
// Get access to the player sprite...
49-
let player = engine.sprites.get_mut("player").unwrap();
50-
// Rotate the player...
51-
player.rotation += std::f32::consts::PI * engine.delta_f32;
52-
// Damage the player if it is out of bounds...
53-
if player.translation.x > 100.0 {
54-
game_state.health -= 1;
55-
}
56-
}
57-
```
16+
use rusty_engine::prelude::*;
17+
// Define a struct to hold custom data for your game. If you don't yet know what data fields you
18+
// need, it can be an empty struct. It must have `#[derive(Resource)]` on the line before it.
19+
#[derive(Resource)]
20+
struct GameState {
21+
health: i32, // add any fields you want, or leave the struct without fields
22+
}
23+
fn main() {
24+
// Create a game
25+
let mut game = Game::new();
26+
// Set up your game. `Game` exposes all of the methods and fields of `Engine`
27+
let sprite = game.add_sprite("player", SpritePreset::RacingCarBlue);
28+
sprite.scale = 2.0;
29+
// Start some music!
30+
game.audio_manager.play_music(MusicPreset::Classy8Bit, 1.0);
31+
// Add one or more functions with logic for your game. When the game is run, the logic
32+
// functions will run in the order they were added.
33+
game.add_logic(game_logic);
34+
// Run the game, with an initial state
35+
game.run(GameState { health: 100 });
36+
}
37+
// Your game logic functions can be named anything, but the first parameter is always a
38+
// `&mut Engine`, and the second parameter is a mutable reference to your custom game
39+
// state struct (`&mut GameState` in this case). The function returns a `bool`.
40+
//
41+
// This function will be run once each frame.
42+
fn game_logic(engine: &mut Engine, game_state: &mut GameState) {
43+
// The `Engine` contains all sorts of built-in goodies.
44+
// Get access to the player sprite...
45+
let player = engine.sprites.get_mut("player").unwrap();
46+
// Rotate the player...
47+
player.rotation += std::f32::consts::PI * engine.delta_f32;
48+
// Damage the player if it is out of bounds...
49+
if player.translation.x > 100.0 {
50+
game_state.health -= 1;
51+
}
52+
}
53+
```
5854

5955
- Run your game with `cargo run --release`. Don't forget the `--release`!
6056

tutorial/src/05-config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Configuration
22

33
- Create a new Rust project
4-
- In your `Cargo.toml` file, add `rusty_engine` to your `[dependencies]` section:
4+
- Do `cargo add rusty_engine` to add the latest version of Rusty Engine to the `[dependencies]` section of your `Cargo.toml`. It should add a line that looks something like this:
55

66
```toml
77
# In your [dependencies] section of Cargo.toml

tutorial/src/10-assets.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Rusty Engine assumes the asset pack is present, so you MUST download the asset pack.
44

55
Here are three different ways to download the assets (pick any of them--it should end up the same in the end):
6-
- RECOMMENDED: On a posix compatible shells run this command inside your project directory:
6+
- RECOMMENDED: In your terminal with a posix-compatible shell, run this command inside your project directory:
77
```shell
88
curl -L https://github.com/CleanCut/rusty_engine/archive/refs/heads/main.tar.gz | tar -zxv --strip-components=1 rusty_engine-main/assets
99
```
@@ -27,7 +27,7 @@ assets
2727
└── rolling
2828
```
2929

30-
You can organize your own custom files wherever you like, but the asset pack will always be organized like this:
30+
You can organize your own custom files inside the `assets` folder wherever you like, but the provided asset pack is organized like this:
3131

3232
- Audio files in `assets/audio`. The asset pack divides sounds into `music` and `sfx` subdirectories.
3333
- Font files in `assets/font`.

tutorial/src/105-keyboard-state.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
You can think of keyboard _state_ as a snapshot of exactly which keys are pressed (or not) at the start of the frame. Keyboard state is best for interactive things like character movement. If you need to process every single keystroke (like when entering text), check out the [Keyboard Event](110-keyboard-events.md) section instead.
44

5-
The `Engine.keyboard_state` field is a struct through which you query the state of the key(s) you are interested in.
5+
The `Engine` struct's `keyboard_state` field is a struct through which you query the state of the key(s) you are interested in.
66

7-
Rusty Engine exposes [Bevy](https://bevyengine.org/)'s [`KeyCode`](https://docs.rs/bevy/latest/bevy/input/keyboard/enum.KeyCode.html) enum directly. See [the `KeyCode` documentation](https://docs.rs/bevy/latest/bevy/input/keyboard/enum.KeyCode.html) for all the possible key variants.
7+
Rusty Engine exposes [Bevy](https://bevyengine.org/)'s [`KeyCode`](https://docs.rs/bevy/latest/bevy/input/keyboard/enum.KeyCode.html) enum through its prelude. See [the `KeyCode` documentation](https://docs.rs/bevy/latest/bevy/input/keyboard/enum.KeyCode.html) for all the possible key variants.
88

99
### Pressed / Released
1010

@@ -54,7 +54,7 @@ if engine.keyboard_state.just_pressed_any(&[KeyCode::Q, KeyCode::F1]) {
5454
// open menu
5555
}
5656
if engine.keyboard_state.just_released_any(&[KeyCode::Space, KeyCode::LControl]) {
57-
// reevaluate your life choices
57+
// re-evaluate your life choices
5858
}
5959
```
6060

tutorial/src/110-keyboard-events.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Keyboard events are passed through from Bevy as instances of the [`KeyboardInput
66

77
```rust,ignored
88
for keyboard_event in game_state.keyboard_events.drain(..) {
9-
// We're using `if let` and a pattern to both destructure the struct and at the
10-
// same time match "Pressed" events containing some key code.
9+
// We're using `if let` and a pattern to destructure the KeyboardInput struct and only look at
10+
// keyboard input if the state is "Pressed". Then we match on the KeyCode and take action.
1111
if let KeyboardInput {
1212
scan_code: _,
1313
key_code: Some(key_code),

0 commit comments

Comments
 (0)