Skip to content

Commit

Permalink
Sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
rewin123 committed Dec 10, 2023
1 parent 72ffe87 commit 4a45872
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 159 deletions.
171 changes: 44 additions & 127 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 1 addition & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,7 @@ default = ["dev"]
# All of Bevy's default features exept for the audio related ones (bevy_audio, vorbis), since they clash with bevy_kira_audio
# and android_shared_stdcxx, since that is covered in `mobile`
[dependencies]
bevy = { version = "0.12.1", default-features = false, features = [
"animation",
"bevy_asset",
"bevy_gilrs",
"bevy_scene",
"bevy_winit",
"bevy_core_pipeline",
"bevy_pbr",
"bevy_gltf",
"bevy_render",
"bevy_sprite",
"bevy_text",
"bevy_ui",
"multi-threaded",
"png",
"hdr",
"x11",
"bevy_gizmos",
"tonemapping_luts",
"default_font",
"webgl2",
] }
bevy_kira_audio = { version = "0.18" }
bevy = { version = "0.12.1" }
bevy_asset_loader = { version = "0.18" }
rand = { version = "0.8.3" }
webbrowser = { version = "0.8", features = ["hardened"] }
Expand Down
Binary file added assets/audio/barking.ogg
Binary file not shown.
Binary file added assets/audio/forest.ogg
Binary file not shown.
Binary file added assets/audio/kill_sound.ogg
Binary file not shown.
Binary file added assets/audio/running-in-grass.ogg
Binary file not shown.
Binary file added assets/audio/sheep.ogg
Binary file not shown.
37 changes: 37 additions & 0 deletions src/ambient.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use bevy::{prelude::*, audio::{PlaybackMode, VolumeLevel, Volume}};

pub struct AmbientPlugin;

#[derive(Resource)]
pub struct ForestAmbient;

impl Plugin for AmbientPlugin {
fn build(&self, app: &mut App) {
app.
add_systems(Startup, startup);
}
}

fn startup(
mut commands: Commands,
asset_server: Res<AssetServer>,
) {
commands.spawn(AudioBundle {
source: asset_server.load("audio/forest.ogg"),
settings: PlaybackSettings {
mode: PlaybackMode::Loop,
..Default::default()
},
..default()
});

commands.spawn(AudioBundle {
source: asset_server.load("audio/sheep.ogg"),
settings: PlaybackSettings {
mode: PlaybackMode::Loop,
..Default::default()
},
..default()
});
}

5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub mod sunday;
pub mod test_level;
pub mod torch;
pub mod wolf;
pub mod ambient;

use std::f32::consts::PI;

Expand Down Expand Up @@ -102,6 +103,10 @@ impl Plugin for GamePlugin {
global_task::GlobalTaskPlugin,
));

app.add_plugins(
ambient::AmbientPlugin
);

//For long term updates
app.insert_resource(Time::<Fixed>::from_seconds(1.0));

Expand Down
Loading

0 comments on commit 4a45872

Please sign in to comment.