theme song
This commit is contained in:
Binary file not shown.
@@ -3,6 +3,7 @@
|
|||||||
"flash_hold_4": File (path: "images/pixelart/Flashlight_hold_4.png"),
|
"flash_hold_4": File (path: "images/pixelart/Flashlight_hold_4.png"),
|
||||||
"flash_hold_4_pressed": File (path: "images/pixelart/Flashlight_click_4.png"),
|
"flash_hold_4_pressed": File (path: "images/pixelart/Flashlight_click_4.png"),
|
||||||
"monster_footsteps": File (path: "audio/monster-footsteps.ogg"),
|
"monster_footsteps": File (path: "audio/monster-footsteps.ogg"),
|
||||||
|
"theme": File (path: "audio/untitled.ogg"),
|
||||||
"house": File (path: "meshes/House.glb"),
|
"house": File (path: "meshes/House.glb"),
|
||||||
"library": Folder (
|
"library": Folder (
|
||||||
path: "meshes/library",
|
path: "meshes/library",
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ pub(crate) struct AudioAssets {
|
|||||||
pub(crate) flash_click: Handle<AudioSource>,
|
pub(crate) flash_click: Handle<AudioSource>,
|
||||||
#[asset(key = "monster_footsteps")]
|
#[asset(key = "monster_footsteps")]
|
||||||
pub(crate) monster_footsteps: Handle<AudioSource>,
|
pub(crate) monster_footsteps: Handle<AudioSource>,
|
||||||
|
#[asset(key = "theme")]
|
||||||
|
pub(crate) theme_song: Handle<AudioSource>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(AssetCollection, Resource, Clone)]
|
#[derive(AssetCollection, Resource, Clone)]
|
||||||
|
|||||||
15
src/main.rs
15
src/main.rs
@@ -1,5 +1,6 @@
|
|||||||
use asset_loading::ImageAssets;
|
use asset_loading::{AudioAssets, ImageAssets};
|
||||||
use bevy::prelude::*;
|
use bevy::{prelude::*};
|
||||||
|
use bevy_kira_audio::{Audio, AudioControl};
|
||||||
use bevy_rapier3d::prelude::*;
|
use bevy_rapier3d::prelude::*;
|
||||||
|
|
||||||
mod asset_loading;
|
mod asset_loading;
|
||||||
@@ -33,6 +34,7 @@ fn main() {
|
|||||||
brightness: 80.0,
|
brightness: 80.0,
|
||||||
})
|
})
|
||||||
.add_systems(OnEnter(GameState::Playing), setup)
|
.add_systems(OnEnter(GameState::Playing), setup)
|
||||||
|
.add_systems(OnEnter(GameState::Menu), play_song)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,3 +79,12 @@ fn setup(
|
|||||||
// Transform::from_xyz(4.0, 8.0, 4.0),
|
// Transform::from_xyz(4.0, 8.0, 4.0),
|
||||||
// ));
|
// ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn play_song(
|
||||||
|
audio_assets: Res<AudioAssets>,
|
||||||
|
audio: Res<Audio>,
|
||||||
|
) {
|
||||||
|
audio.play(audio_assets.theme_song.clone())
|
||||||
|
.looped()
|
||||||
|
.with_volume(0.35);
|
||||||
|
}
|
||||||
@@ -345,7 +345,7 @@ fn play_footstep_segment(
|
|||||||
// start_time += rand.random_range(0.0..5.0);
|
// start_time += rand.random_range(0.0..5.0);
|
||||||
|
|
||||||
audio.play(audio_assets.monster_footsteps.clone())
|
audio.play(audio_assets.monster_footsteps.clone())
|
||||||
.with_volume(Volume::Amplitude(volume as f64))
|
.with_volume(volume as f64)
|
||||||
.start_from((start_time as f64).min(27.0))
|
.start_from((start_time as f64).min(27.0))
|
||||||
.fade_in(AudioTween::linear(Duration::from_millis(100)))
|
.fade_in(AudioTween::linear(Duration::from_millis(100)))
|
||||||
.handle();
|
.handle();
|
||||||
|
|||||||
Reference in New Issue
Block a user