diff --git a/assets/credits.md b/assets/credits.md index d564e31..60af30d 100644 --- a/assets/credits.md +++ b/assets/credits.md @@ -3,3 +3,4 @@ ## Audio - [explosion.ogg](https://freesound.org/people/Werra/sounds/244394/) - edited +- [music.ogg](https://freesound.org/people/ShadyDave/sounds/325647/) - edited diff --git a/assets/sounds/music.ogg b/assets/sounds/music.ogg new file mode 100644 index 0000000..ab1788d Binary files /dev/null and b/assets/sounds/music.ogg differ diff --git a/src/audio.rs b/src/audio.rs index 2fedbf8..31568ac 100644 --- a/src/audio.rs +++ b/src/audio.rs @@ -2,6 +2,7 @@ use bevy::prelude::*; use bevy_cameraman::Cameraman; const DEBUG: bool = false; +const MUSIC_AUDIO_ID: &str = "sounds/music.ogg"; pub struct AudioPlugin; @@ -11,10 +12,19 @@ impl Plugin for AudioPlugin { } } -fn setup(mut commands: Commands, query_camera: Query>) { +fn setup( + mut commands: Commands, + server: Res, + query_camera: Query>, +) { let gap = 200.; let listener = SpatialListener::new(gap); + commands.spawn(AudioBundle { + source: server.load(MUSIC_AUDIO_ID), + settings: PlaybackSettings::LOOP.with_spatial(false), + }); + for entity in &query_camera { let mut cmd = commands.entity(entity); let cmd = cmd.insert((SpatialBundle::default(), listener.clone()));