Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Bevy 0.13 #70

Merged
merged 6 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ license = "MIT OR Apache-2.0"

[dependencies]
anyhow = "1.0"
bevy = { version = "0.12", default-features = false, features = ["bevy_audio"] }
bevy = { version = "0.13", default-features = false, features = ["bevy_audio"] }
bevy_mod_sysfail = "3.0"
libfmod = "~2.206.2"

[dev-dependencies]
# The examples need the default features of bevy
bevy = { version = "0.12", default-features = true }
bevy = { version = "0.13", default-features = true }

[features]
default = []
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ This requires a free FMOD account.
- Install the package.
- You need the following 4 files in the root of your rust project:
- `api/core/lib/x64/fmod.dll`
- `api/core/lib/x64/fmod_vc.lib`: **rename to `fmod.lib`**
- `api/core/lib/x64/fmod_vc.lib`
- `api/studio/lib/x64/fmodstudio.dll`
- `api/studio/lib/x64/fmodstudio_vc.lib`: **rename to `fmodstudio.lib`**
- `api/studio/lib/x64/fmodstudio_vc.lib`

### Linux

Expand Down
8 changes: 4 additions & 4 deletions examples/audio_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ fn play_music(mut audio_sources: Query<&AudioSource, With<MyMusicPlayer>>) {
audio_sources.single_mut().play();
}

fn audio_control(query: Query<&AudioSource>, input: Res<Input<KeyCode>>) {
if input.just_pressed(KeyCode::S) {
fn audio_control(query: Query<&AudioSource>, input: Res<ButtonInput<KeyCode>>) {
if input.just_pressed(KeyCode::KeyS) {
for audio_player in query.iter() {
audio_player.stop();
}
}

if input.just_pressed(KeyCode::P) {
if input.just_pressed(KeyCode::KeyP) {
for audio_player in query.iter() {
audio_player.play();
}
}

if input.just_pressed(KeyCode::T) {
if input.just_pressed(KeyCode::KeyT) {
for audio_player in query.iter() {
audio_player.toggle();
}
Expand Down
21 changes: 12 additions & 9 deletions examples/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ fn main() {
DefaultPlugins,
FmodPlugin {
audio_banks_paths: &[
"./assets/Master.bank",
"./assets/Master.strings.bank",
"./assets/SFX.bank",
"./assets/audio/demo_project/Build/Desktop/Master.bank",
"./assets/audio/demo_project/Build/Desktop/Master.strings.bank",
"./assets/audio/demo_project/Build/Desktop/SFX.bank",
],
},
))
Expand Down Expand Up @@ -82,8 +82,11 @@ fn play_music(audio_sources: Query<&AudioSource>) {
}
}

fn set_rain(audio_sources: Query<&AudioSource, With<ForestSfxPlayer>>, input: Res<Input<KeyCode>>) {
if input.just_pressed(KeyCode::Up) {
fn set_rain(
audio_sources: Query<&AudioSource, With<ForestSfxPlayer>>,
input: Res<ButtonInput<KeyCode>>,
) {
if input.just_pressed(KeyCode::ArrowUp) {
for audio_source in audio_sources.iter() {
audio_source
.event_instance
Expand All @@ -92,7 +95,7 @@ fn set_rain(audio_sources: Query<&AudioSource, With<ForestSfxPlayer>>, input: Re
}
}

if input.just_pressed(KeyCode::Down) {
if input.just_pressed(KeyCode::ArrowDown) {
for audio_source in audio_sources.iter() {
audio_source
.event_instance
Expand All @@ -104,9 +107,9 @@ fn set_rain(audio_sources: Query<&AudioSource, With<ForestSfxPlayer>>, input: Re

fn set_hour(
audio_sources: Query<&AudioSource, With<CountrySfxPlayer>>,
input: Res<Input<KeyCode>>,
input: Res<ButtonInput<KeyCode>>,
) {
if input.just_pressed(KeyCode::E) {
if input.just_pressed(KeyCode::KeyE) {
for audio_source in audio_sources.iter() {
audio_source
.event_instance
Expand All @@ -115,7 +118,7 @@ fn set_hour(
}
}

if input.just_pressed(KeyCode::M) {
if input.just_pressed(KeyCode::KeyM) {
for audio_source in audio_sources.iter() {
audio_source
.event_instance
Expand Down
20 changes: 9 additions & 11 deletions examples/spatial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use bevy::prelude::*;
use bevy_fmod::prelude::AudioSource;
use bevy_fmod::prelude::SpatialAudioBundle;
use bevy_fmod::prelude::*;

fn main() {
Expand Down Expand Up @@ -37,16 +36,15 @@ fn setup_scene(
) {
// Plane
commands.spawn(PbrBundle {
mesh: meshes.add(shape::Plane::from_size(5.0).into()),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
transform: Transform::from_xyz(0.0, -1.0, 0.0),
..default()
});

// Light
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 1500.0,
shadows_enabled: true,
..default()
},
Expand All @@ -68,8 +66,8 @@ fn setup_scene(
commands
.spawn(SpatialAudioBundle::new(event_description))
.insert(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::default()),
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
transform: Transform::from_scale(Vec3::splat(0.2)),
..default()
});
Expand All @@ -90,24 +88,24 @@ fn orbit_audio_source(
}

fn update_listener(
keyboard: Res<Input<KeyCode>>,
keyboard: Res<ButtonInput<KeyCode>>,
time: Res<Time>,
mut listeners: Query<&mut Transform, With<AudioListener>>,
) {
let mut transform = listeners.single_mut();

let speed = 4.;

if keyboard.pressed(KeyCode::Right) {
if keyboard.pressed(KeyCode::ArrowRight) {
transform.translation.x += speed * time.delta_seconds();
}
if keyboard.pressed(KeyCode::Left) {
if keyboard.pressed(KeyCode::ArrowLeft) {
transform.translation.x -= speed * time.delta_seconds();
}
if keyboard.pressed(KeyCode::Down) {
if keyboard.pressed(KeyCode::ArrowDown) {
transform.translation.z += speed * time.delta_seconds();
}
if keyboard.pressed(KeyCode::Up) {
if keyboard.pressed(KeyCode::ArrowUp) {
transform.translation.z -= speed * time.delta_seconds();
}
}