diff --git a/README.md b/README.md index 8b10214..fc54ebc 100644 --- a/README.md +++ b/README.md @@ -294,6 +294,7 @@ python -m http.server -d wasm - https://pixabay.com/sound-effects/box-crash-106687 - https://pixabay.com/sound-effects/electric-fan-motor-blades-removed-13169 - https://pixabay.com/sound-effects/whoosh-blow-flutter-shortwav-14678/ + - https://pixabay.com/sound-effects/dslr-camera-sounds-26117/ - Music: [Cinematic Cello](https://pixabay.com/music/build-up-scenes-cinematic-cello-115667) by [Aleksey Chistilin](https://pixabay.com/users/lexin_music-28841948/), [Pixabay Content License](https://pixabay.com/service/license-summary) - Star chart based on the [HYG Stellar database](https://github.com/astronexus/HYG-Database) - Font Yupiter-Regular.ttf is placed under the SIL OPEN FONT LICENSE Version 1.1 and is based on: diff --git a/assets/sounds/zoom.ogg b/assets/sounds/zoom.ogg new file mode 100644 index 0000000..35b98ad Binary files /dev/null and b/assets/sounds/zoom.ogg differ diff --git a/src/audio.rs b/src/audio.rs index 69ed435..942a6b0 100644 --- a/src/audio.rs +++ b/src/audio.rs @@ -12,11 +12,12 @@ use bevy::prelude::*; use bevy::audio::{PlaybackMode, Volume}; -use crate::var; +use crate::{camera, var}; const ASSET_CLICK: &str = "sounds/click-button-140881-crop.ogg"; const ASSET_SWITCH: &str = "sounds/typosonic-typing-192811-crop.ogg"; const ASSET_WOOSH: &str = "sounds/woosh.ogg"; +const ASSET_ZOOM: &str = "sounds/zoom.ogg"; const ASSET_INCOMING_MESSAGE: &str = "sounds/connect.ogg"; const ASSET_PING: &str = "sounds/connect.ogg"; const ASSET_CONNECT: &str = "sounds/connect.ogg"; @@ -34,18 +35,24 @@ impl Plugin for AudioPlugin { fn build(&self, app: &mut App) { app.add_systems(Startup, setup); app.add_systems(Update, toggle_bgm); + app.add_systems(Update, play_zoom_sfx); app.add_systems(PostUpdate, play_sfx); app.add_systems(PostUpdate, update_music); app.add_event::(); app.add_event::(); + app.insert_resource(ZoomTimer( + Timer::from_seconds(0.09, TimerMode::Repeating))); } } +#[derive(Resource)] pub struct ZoomTimer(Timer); + pub enum Sfx { IncomingChatMessage, Click, Switch, Woosh, + Zoom, Ping, Connect, EnterVehicle, @@ -65,6 +72,7 @@ pub enum Sfx { #[derive(Resource)] pub struct SoundClick(Handle); #[derive(Resource)] pub struct SoundSwitch(Handle); #[derive(Resource)] pub struct SoundWoosh(Handle); +#[derive(Resource)] pub struct SoundZoom(Handle); #[derive(Resource)] pub struct SoundIncomingMessage(Handle); #[derive(Resource)] pub struct SoundPing(Handle); #[derive(Resource)] pub struct SoundConnect(Handle); @@ -139,6 +147,7 @@ pub fn setup( commands.insert_resource(SoundClick(asset_server.load(ASSET_CLICK))); commands.insert_resource(SoundSwitch(asset_server.load(ASSET_SWITCH))); commands.insert_resource(SoundWoosh(asset_server.load(ASSET_WOOSH))); + commands.insert_resource(SoundZoom(asset_server.load(ASSET_ZOOM))); commands.insert_resource(SoundIncomingMessage(asset_server.load(ASSET_INCOMING_MESSAGE))); commands.insert_resource(SoundPing(asset_server.load(ASSET_PING))); commands.insert_resource(SoundConnect(asset_server.load(ASSET_CONNECT))); @@ -172,6 +181,7 @@ pub fn play_sfx( sound_click: Res, sound_switch: Res, sound_woosh: Res, + sound_zoom: Res, sound_incoming_message: Res, sound_ping: Res, sound_connect: Res, @@ -192,6 +202,7 @@ pub fn play_sfx( Sfx::Switch => sound_switch.0.clone(), Sfx::Click => sound_click.0.clone(), Sfx::Woosh => sound_woosh.0.clone(), + Sfx::Zoom => sound_zoom.0.clone(), Sfx::IncomingChatMessage => sound_incoming_message.0.clone(), Sfx::Ping => sound_ping.0.clone(), Sfx::Connect => sound_connect.0.clone(), @@ -209,6 +220,8 @@ pub fn str2sfx(sfx_label: &str) -> Sfx { return match sfx_label { "switch" => Sfx::Switch, "click" => Sfx::Click, + "woosh" => Sfx::Woosh, + "zoom" => Sfx::Zoom, "chat" => Sfx::IncomingChatMessage, "ping" => Sfx::Ping, "connect" => Sfx::Connect, @@ -235,3 +248,22 @@ pub fn update_music( } } } + +pub fn play_zoom_sfx( + time: Res