Skip to content

Commit

Permalink
Merge pull request #43 from arcashka/bevy_main_0_13
Browse files Browse the repository at this point in the history
Update to bevy 0.13
  • Loading branch information
sburris0 authored Mar 7, 2024
2 parents 2ce0ead + 24c0f78 commit baffe50
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 39 deletions.
19 changes: 16 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_flycam"
version = "0.12.0"
version = "0.13.0"
authors = ["Spencer Burris <sburris@posteo.net>"]
edition = "2021"
license = "ISC"
Expand All @@ -13,7 +13,20 @@ categories = ["game-engines", "game-development"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bevy = { version = "0.12", default-features = false, features = ["bevy_render", "bevy_core_pipeline", "bevy_asset"] }
bevy = { version = "0.13", default-features = false, features = [
"bevy_render",
"bevy_core_pipeline",
"bevy_asset",
] }

[dev-dependencies]
bevy = { version = "0.12", default-features = false, features = ["x11", "wayland", "bevy_pbr", "bevy_core_pipeline", "bevy_asset", "ktx2", "zstd", "tonemapping_luts"] }
bevy = { version = "0.13", default-features = false, features = [
"x11",
"wayland",
"bevy_pbr",
"bevy_core_pipeline",
"bevy_asset",
"ktx2",
"zstd",
"tonemapping_luts",
] }
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
![Crates.io](https://img.shields.io/crates/l/bevy_flycam)
![docs.rs](https://img.shields.io/docsrs/bevy_flycam)

A basic first-person fly camera for Bevy 0.12
A basic first-person fly camera for Bevy 0.13

## Controls

Expand All @@ -29,15 +29,15 @@ There are a few notable differences from [bevy_fly_camera](https://github.com/mc

```toml
[dependencies]
bevy = "0.11"
bevy = "0.13"
bevy_flycam = "*"
```

or

```toml
[dependencies]
bevy = "0.11"
bevy = "0.13"
bevy_flycam = { git = "https://github.com/sburris0/bevy_flycam" }
```

Expand Down Expand Up @@ -123,6 +123,7 @@ fn setup(mut commands: Commands) {
bevy_flycam's crate version follows bevy's minor version as shown:
| bevy | bevy_flycam |
| :-- | :-- |
| `0.13.0` | `0.13.0` |
| `0.12.0` | `0.12.0` |
| `0.11.0` | `0.11.0` |
| `0.10.1` | `0.10.1` |
Expand Down
11 changes: 4 additions & 7 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,15 @@ fn setup(
) {
// plane
commands.spawn((PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane {
size: 5.0,
..Default::default()
})),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
mesh: meshes.add(Plane3d::new(Vec3::Y).mesh().size(5.0, 5.0)),
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
..Default::default()
},));

// cube
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..Default::default()
});
Expand Down
15 changes: 6 additions & 9 deletions examples/key_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ fn main() {
})
// Unreal movement layout
.insert_resource(KeyBindings {
move_ascend: KeyCode::E,
move_descend: KeyCode::Q,
move_ascend: KeyCode::KeyE,
move_descend: KeyCode::KeyQ,
..Default::default()
})
.add_systems(Startup, setup)
Expand All @@ -31,18 +31,15 @@ fn setup(
) {
// plane
commands.spawn((PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane {
size: 5.0,
..Default::default()
})),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
mesh: meshes.add(Plane3d::new(Vec3::Y).mesh().size(5.0, 5.0)),
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
..Default::default()
},));

// cube
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..Default::default()
});
Expand Down
19 changes: 8 additions & 11 deletions examples/scroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() {
..Default::default()
})
// Setting initial state
.add_state::<ScrollType>()
.init_state::<ScrollType>()
.add_systems(Startup, setup)
.add_systems(Update, switch_scroll_type)
.add_systems(Update, scroll)
Expand All @@ -36,18 +36,15 @@ fn setup(
) {
// plane
commands.spawn((PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane {
size: 5.0,
..Default::default()
})),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
mesh: meshes.add(Plane3d::new(Vec3::Y).mesh().size(5.0, 5.0)),
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
..Default::default()
},));

// cube
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..Default::default()
});
Expand Down Expand Up @@ -75,9 +72,9 @@ fn setup(
fn switch_scroll_type(
scroll_type: Res<State<ScrollType>>,
mut next_scroll_type: ResMut<NextState<ScrollType>>,
keyboard_input: Res<Input<KeyCode>>,
keyboard_input: Res<ButtonInput<KeyCode>>,
) {
if keyboard_input.just_pressed(KeyCode::Z) {
if keyboard_input.just_pressed(KeyCode::KeyZ) {
let result = match scroll_type.get() {
ScrollType::MovementSpeed => ScrollType::Zoom,
ScrollType::Zoom => ScrollType::MovementSpeed,
Expand All @@ -95,7 +92,7 @@ fn scroll(
mut mouse_wheel_events: EventReader<MouseWheel>,
mut query: Query<(&FlyCam, &mut Projection)>,
) {
for event in mouse_wheel_events.iter() {
for event in mouse_wheel_events.read() {
if *scroll_type.get() == ScrollType::MovementSpeed {
settings.speed = (settings.speed + event.y * 0.1).abs();
println!("Speed: {:?}", settings.speed);
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ pub struct KeyBindings {
impl Default for KeyBindings {
fn default() -> Self {
Self {
move_forward: KeyCode::W,
move_backward: KeyCode::S,
move_left: KeyCode::A,
move_right: KeyCode::D,
move_forward: KeyCode::KeyW,
move_backward: KeyCode::KeyS,
move_left: KeyCode::KeyA,
move_right: KeyCode::KeyD,
move_ascend: KeyCode::Space,
move_descend: KeyCode::ShiftLeft,
toggle_grab_cursor: KeyCode::Escape,
Expand Down Expand Up @@ -96,7 +96,7 @@ fn setup_player(mut commands: Commands) {

/// Handles keyboard input and movement
fn player_move(
keys: Res<Input<KeyCode>>,
keys: Res<ButtonInput<KeyCode>>,
time: Res<Time>,
primary_window: Query<&Window, With<PrimaryWindow>>,
settings: Res<MovementSettings>,
Expand Down Expand Up @@ -176,7 +176,7 @@ fn player_look(
}

fn cursor_grab(
keys: Res<Input<KeyCode>>,
keys: Res<ButtonInput<KeyCode>>,
key_bindings: Res<KeyBindings>,
mut primary_window: Query<&mut Window, With<PrimaryWindow>>,
) {
Expand Down

0 comments on commit baffe50

Please sign in to comment.