round door to doors

This commit is contained in:
AmadeusWM
2025-04-06 23:17:26 +02:00
parent 8c5081b2dc
commit 902ed398e4
3 changed files with 54 additions and 41 deletions

View File

@@ -165,7 +165,7 @@ fn spawn_level(
pos.with_rotation(Quat::from_rotation_y(90.0_f32.to_radians())), pos.with_rotation(Quat::from_rotation_y(90.0_f32.to_radians())),
), ),
( (
round_door.clone(), door.clone(),
pos.with_rotation(Quat::from_rotation_y(180.0_f32.to_radians())), pos.with_rotation(Quat::from_rotation_y(180.0_f32.to_radians())),
), ),
( (
@@ -181,7 +181,7 @@ fn spawn_level(
pos.with_rotation(Quat::from_rotation_y(90.0_f32.to_radians())), pos.with_rotation(Quat::from_rotation_y(90.0_f32.to_radians())),
), ),
( (
round_door.clone(), door.clone(),
pos.with_rotation(Quat::from_rotation_y(0.0_f32.to_radians())), pos.with_rotation(Quat::from_rotation_y(0.0_f32.to_radians())),
), ),
( (
@@ -194,7 +194,7 @@ fn spawn_level(
vec![ vec![
(wall.clone(), pos), (wall.clone(), pos),
( (
round_door.clone(), door.clone(),
pos.with_rotation(Quat::from_rotation_y(90.0_f32.to_radians())), pos.with_rotation(Quat::from_rotation_y(90.0_f32.to_radians())),
), ),
( (
@@ -207,7 +207,7 @@ fn spawn_level(
vec![ vec![
(wall.clone(), pos), (wall.clone(), pos),
( (
round_door.clone(), door.clone(),
pos.with_rotation(Quat::from_rotation_y(270.0_f32.to_radians())), pos.with_rotation(Quat::from_rotation_y(270.0_f32.to_radians())),
), ),
( (

View File

@@ -295,23 +295,33 @@ fn play_monster_sounds(
if monster.footstep_timer.just_finished() { if monster.footstep_timer.just_finished() {
match monster.state { match monster.state {
MonsterState::Hunting => { MonsterState::Hunting => {
monster.footstep_timer = Timer::from_seconds(1.5, TimerMode::Once); monster.footstep_timer = Timer::from_seconds(10.0, TimerMode::Once);
monster.speed = 2.0
}, },
MonsterState::Lurking | MonsterState::Wandering => { MonsterState::Lurking | MonsterState::Wandering => {
monster.footstep_timer = Timer::from_seconds( monster.footstep_timer = Timer::from_seconds(
rand.random_range(3.0..7.0), 10.0,
TimerMode::Once TimerMode::Once
); );
monster.speed = 1.0
}, },
MonsterState::Dormant => { MonsterState::Dormant => {
monster.footstep_timer = Timer::from_seconds( monster.footstep_timer = Timer::from_seconds(
rand.random_range(10.0..20.0), 10.0,
TimerMode::Once TimerMode::Once
); );
monster.speed = 0.0
} }
} }
play_footstep_segment(audio, &audio_assets, distance, &monster.state, monster.footstep_timer.duration().as_secs_f32()); play_footstep_segment(
audio,
&audio_assets,
distance,
&monster.state,
monster.footstep_timer.duration().as_secs_f32(),
monster.speed
);
if monster.state == MonsterState::Hunting && rand.random_bool(0.3) { if monster.state == MonsterState::Hunting && rand.random_bool(0.3) {
println!("Monster growl!"); println!("Monster growl!");
@@ -325,7 +335,8 @@ fn play_footstep_segment(
audio_assets: &Res<AudioAssets>, audio_assets: &Res<AudioAssets>,
distance: f32, distance: f32,
state: &MonsterState, state: &MonsterState,
dur: f32 dur: f32,
speed: f32
) { ) {
let base_volume: f32 = match state { let base_volume: f32 = match state {
MonsterState::Dormant => 0.6, MonsterState::Dormant => 0.6,
@@ -335,7 +346,7 @@ fn play_footstep_segment(
}; };
// adjust volume based on distance (closer = louder) // adjust volume based on distance (closer = louder)
let distance_factor: f32 = 1.0 - (distance / 100.0).clamp(0.0, 1.0); let distance_factor: f32 = (1.0 - distance / 30.0).clamp(0.0, 1.0);
let volume = base_volume * distance_factor; let volume = base_volume * distance_factor;
// play only a short segment of the footstep sound // play only a short segment of the footstep sound
@@ -344,10 +355,12 @@ fn play_footstep_segment(
// let mut rand = rand::rng(); // let mut rand = rand::rng();
// start_time += rand.random_range(0.0..5.0); // start_time += rand.random_range(0.0..5.0);
audio.stop();
audio.play(audio_assets.monster_footsteps.clone()) audio.play(audio_assets.monster_footsteps.clone())
.with_volume(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)))
.with_playback_rate(speed as f64)
.handle(); .handle();
println!("Monster footstep: State={:?}, Distance={:.2}, Volume={:.2}, Dur={:1}, Start={:1}", println!("Monster footstep: State={:?}, Distance={:.2}, Volume={:.2}, Dur={:1}, Start={:1}",

View File

@@ -457,9 +457,9 @@ pub fn handle_spotlight(
pub fn update_flashlight_charge(time: Res<Time>, mut flashlight_query: Query<&mut Flashlight>) { pub fn update_flashlight_charge(time: Res<Time>, mut flashlight_query: Query<&mut Flashlight>) {
for mut flashlight in flashlight_query.iter_mut() { for mut flashlight in flashlight_query.iter_mut() {
if flashlight.is_on { if flashlight.is_on {
flashlight.charge = flashlight.charge - time.delta_secs() * 0.1; flashlight.charge = flashlight.charge - time.delta_secs() * 0.2;
} else { } else {
flashlight.charge = flashlight.charge + time.delta_secs() * 0.1; flashlight.charge = flashlight.charge + time.delta_secs() * 0.2;
} }
flashlight.charge = flashlight.charge.clamp(0.0, 4.0); flashlight.charge = flashlight.charge.clamp(0.0, 4.0);
if flashlight.charge <= 0.0 { if flashlight.charge <= 0.0 {