mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add footstep sounds, implement crude footstep sounding
Sounds are played every tick, which is not good.
This commit is contained in:
BIN
assets/voxygen/audio/footsteps/stepdirt_1.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepdirt_1.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepdirt_2.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepdirt_2.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepdirt_3.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepdirt_3.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepdirt_4.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepdirt_4.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepdirt_5.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepdirt_5.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepdirt_6.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepdirt_6.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepdirt_7.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepdirt_7.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepdirt_8.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepdirt_8.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepsnow_1.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepsnow_1.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepsnow_2.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepsnow_2.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepstone_1.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepstone_1.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepstone_2.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepstone_2.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepstone_3.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepstone_3.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepstone_4.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepstone_4.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepstone_5.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepstone_5.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepstone_6.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepstone_6.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepstone_7.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepstone_7.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepstone_8.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepstone_8.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepwater_1.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepwater_1.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepwater_2.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepwater_2.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepwood_1.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepwood_1.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/footsteps/stepwood_2.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/footsteps/stepwood_2.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -4,7 +4,7 @@ use fader::Fader;
|
|||||||
use channel::{AudioType, Channel};
|
use channel::{AudioType, Channel};
|
||||||
|
|
||||||
use common::assets;
|
use common::assets;
|
||||||
use rodio::{Decoder, Device, Sink, SpatialSink};
|
use rodio::{Decoder, Device, SpatialSink};
|
||||||
|
|
||||||
const LEFT_EAR : [f32; 3] = [1.0, 0.0, 0.0];
|
const LEFT_EAR : [f32; 3] = [1.0, 0.0, 0.0];
|
||||||
const RIGHT_EAR : [f32; 3] = [-1.0, 0.0, 0.0];
|
const RIGHT_EAR : [f32; 3] = [-1.0, 0.0, 0.0];
|
||||||
|
@ -35,7 +35,6 @@ impl PlayState for MainMenuState {
|
|||||||
let mut client_init: Option<ClientInit> = None;
|
let mut client_init: Option<ClientInit> = None;
|
||||||
|
|
||||||
let music = global_state.audio.play_music("voxygen.audio.soundtrack.veloren_title_tune-3".to_string());
|
let music = global_state.audio.play_music("voxygen.audio.soundtrack.veloren_title_tune-3".to_string());
|
||||||
global_state.audio.stop_channel(music, Fader::fade_out(10.0));
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// Handle window events.
|
// Handle window events.
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
pub mod camera;
|
pub mod camera;
|
||||||
pub mod figure;
|
pub mod figure;
|
||||||
pub mod terrain;
|
pub mod terrain;
|
||||||
|
pub mod sound;
|
||||||
|
|
||||||
use self::{
|
use self::{
|
||||||
camera::{Camera, CameraMode},
|
camera::{Camera, CameraMode},
|
||||||
figure::FigureMgr,
|
figure::FigureMgr,
|
||||||
terrain::Terrain,
|
terrain::Terrain,
|
||||||
|
sound::SoundMgr,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
render::{
|
render::{
|
||||||
@ -13,6 +15,7 @@ use crate::{
|
|||||||
PostProcessPipeline, Renderer, SkyboxLocals, SkyboxPipeline,
|
PostProcessPipeline, Renderer, SkyboxLocals, SkyboxPipeline,
|
||||||
},
|
},
|
||||||
window::Event,
|
window::Event,
|
||||||
|
audio::AudioFrontend,
|
||||||
};
|
};
|
||||||
use client::Client;
|
use client::Client;
|
||||||
use common::{comp, terrain::BlockKind, vol::ReadVol};
|
use common::{comp, terrain::BlockKind, vol::ReadVol};
|
||||||
@ -46,6 +49,7 @@ pub struct Scene {
|
|||||||
loaded_distance: f32,
|
loaded_distance: f32,
|
||||||
|
|
||||||
figure_mgr: FigureMgr,
|
figure_mgr: FigureMgr,
|
||||||
|
sound_mgr: SoundMgr,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Scene {
|
impl Scene {
|
||||||
@ -71,6 +75,7 @@ impl Scene {
|
|||||||
terrain: Terrain::new(renderer),
|
terrain: Terrain::new(renderer),
|
||||||
loaded_distance: 0.0,
|
loaded_distance: 0.0,
|
||||||
figure_mgr: FigureMgr::new(),
|
figure_mgr: FigureMgr::new(),
|
||||||
|
sound_mgr: SoundMgr::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +120,7 @@ impl Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Maintain data such as GPU constant buffers, models, etc. To be called once per tick.
|
/// Maintain data such as GPU constant buffers, models, etc. To be called once per tick.
|
||||||
pub fn maintain(&mut self, renderer: &mut Renderer, client: &Client) {
|
pub fn maintain(&mut self, renderer: &mut Renderer, audio: &mut AudioFrontend, client: &Client) {
|
||||||
// Get player position.
|
// Get player position.
|
||||||
let player_pos = client
|
let player_pos = client
|
||||||
.state()
|
.state()
|
||||||
@ -219,6 +224,9 @@ impl Scene {
|
|||||||
|
|
||||||
// Remove unused figures.
|
// Remove unused figures.
|
||||||
self.figure_mgr.clean(client.get_tick());
|
self.figure_mgr.clean(client.get_tick());
|
||||||
|
|
||||||
|
// Maintain audio
|
||||||
|
self.sound_mgr.maintain(audio, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Render the scene using the provided `Renderer`.
|
/// Render the scene using the provided `Renderer`.
|
||||||
|
53
voxygen/src/scene/sound.rs
Normal file
53
voxygen/src/scene/sound.rs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
use crate::{
|
||||||
|
audio::AudioFrontend,
|
||||||
|
};
|
||||||
|
use common::comp::{
|
||||||
|
Pos,
|
||||||
|
Body,
|
||||||
|
CharacterState,
|
||||||
|
MovementState::*,
|
||||||
|
};
|
||||||
|
use client::Client;
|
||||||
|
use vek::*;
|
||||||
|
use specs::{Entity as EcsEntity, Join};
|
||||||
|
|
||||||
|
pub struct SoundMgr {
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SoundMgr {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn maintain(&mut self, audio: &mut AudioFrontend, client: &Client) {
|
||||||
|
let time = client.state().get_time();
|
||||||
|
let tick = client.get_tick();
|
||||||
|
let ecs = client.state().ecs();
|
||||||
|
let dt = client.state().get_delta_time();
|
||||||
|
// Get player position.
|
||||||
|
let player_pos = ecs
|
||||||
|
.read_storage::<Pos>()
|
||||||
|
.get(client.entity())
|
||||||
|
.map_or(Vec3::zero(), |pos| pos.0);
|
||||||
|
|
||||||
|
for (entity, pos, body, character) in (
|
||||||
|
&ecs.entities(),
|
||||||
|
&ecs.read_storage::<Pos>(),
|
||||||
|
&ecs.read_storage::<Body>(),
|
||||||
|
ecs.read_storage::<CharacterState>().maybe(),
|
||||||
|
)
|
||||||
|
.join()
|
||||||
|
{
|
||||||
|
if let Body::Humanoid(_) = body {
|
||||||
|
let character = match character {
|
||||||
|
Some(c) => c,
|
||||||
|
_ => continue,
|
||||||
|
};
|
||||||
|
if let Run = &character.movement {
|
||||||
|
let rand_step = (rand::random::<usize>() % 7) + 1;
|
||||||
|
audio.play_sound(format!("voxygen.audio.footsteps.stepdirt_{}", rand_step));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -389,7 +389,7 @@ impl PlayState for SessionState {
|
|||||||
|
|
||||||
// Maintain the scene.
|
// Maintain the scene.
|
||||||
self.scene
|
self.scene
|
||||||
.maintain(global_state.window.renderer_mut(), &self.client.borrow());
|
.maintain(global_state.window.renderer_mut(), &mut global_state.audio, &self.client.borrow());
|
||||||
|
|
||||||
// Render the session.
|
// Render the session.
|
||||||
self.render(global_state.window.renderer_mut());
|
self.render(global_state.window.renderer_mut());
|
||||||
|
Reference in New Issue
Block a user