fix(wasm): request permission for media autoplay if needed
This commit is contained in:
parent
32c67d46d5
commit
53bf4b1aef
14 changed files with 44 additions and 467 deletions
42
src/game.rs
42
src/game.rs
|
|
@ -2,8 +2,8 @@
|
|||
#![allow(clippy::too_many_arguments)]
|
||||
|
||||
pub use crate::filters::*;
|
||||
use crate::{AppState, audio_system};
|
||||
use crate::levels;
|
||||
use crate::{audio_system, AppState};
|
||||
|
||||
use bevy::{
|
||||
ecs::system::EntityCommands,
|
||||
|
|
@ -337,7 +337,7 @@ fn char_char_collision_event_system(
|
|||
c1_player.is_some() || c2_player.is_some(),
|
||||
);
|
||||
|
||||
audio_system::play_audio(&audio_assets.warp_notes, &audio, new_color.into(), 1.0);
|
||||
audio_system::play_audio(&audio_assets.warp_notes, &audio, new_color, 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -364,7 +364,7 @@ fn char_platform_collision_event_system(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CollisionEvent::Stopped(e1, e2, flags) => {
|
||||
if *flags == CollisionEventFlags::SENSOR {
|
||||
if let (Ok(mut platform_count), Ok(_)) =
|
||||
|
|
@ -412,25 +412,14 @@ fn collision_event_system(
|
|||
}
|
||||
}
|
||||
} else if *flags == CollisionEventFlags::SENSOR {
|
||||
if let (Ok((mut c_color, _c_transform, mut c_material, c_player)), Ok(filter)) = (
|
||||
if let (Ok((mut c_color, _c_transform, mut c_material, _c_player)), Ok(filter)) = (
|
||||
character_query.get_mut(*e1),
|
||||
pass_through_filter_query.get(*e2),
|
||||
) {
|
||||
c_color.0 = filter.apply(c_color.0);
|
||||
*c_material = materials.add(ColorMaterial::from(c_color.0));
|
||||
|
||||
if c_player.is_some() {
|
||||
audio
|
||||
.send(AudioMsg::Color([
|
||||
c_color.0.r(),
|
||||
c_color.0.g(),
|
||||
c_color.0.b(),
|
||||
]))
|
||||
.ok();
|
||||
audio.send(AudioMsg::Switch).ok();
|
||||
}
|
||||
} else if let (
|
||||
Ok((mut c_color, _c_transform, mut c_material, c_player)),
|
||||
Ok((mut c_color, _c_transform, mut c_material, _c_player)),
|
||||
Ok(filter),
|
||||
) = (
|
||||
character_query.get_mut(*e2),
|
||||
|
|
@ -438,17 +427,6 @@ fn collision_event_system(
|
|||
) {
|
||||
c_color.0 = filter.apply(c_color.0);
|
||||
*c_material = materials.add(ColorMaterial::from(c_color.0));
|
||||
|
||||
if c_player.is_some() {
|
||||
audio
|
||||
.send(AudioMsg::Color([
|
||||
c_color.0.r(),
|
||||
c_color.0.g(),
|
||||
c_color.0.b(),
|
||||
]))
|
||||
.ok();
|
||||
audio.send(AudioMsg::Switch).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -568,8 +546,8 @@ fn camera_system(
|
|||
time: Res<Time>,
|
||||
mut zoom_timer: ResMut<levels::ZoomTimer>,
|
||||
) {
|
||||
fn lerp(x: f32, y: f32, t: f32,) -> f32 {
|
||||
return ((y - x) * t) + x;
|
||||
fn lerp(x: f32, y: f32, t: f32) -> f32 {
|
||||
((y - x) * t) + x
|
||||
}
|
||||
|
||||
const MARGIN: f32 = 300.0;
|
||||
|
|
@ -637,7 +615,11 @@ fn level_keyboard_system(
|
|||
commands.entity(entity).despawn_recursive();
|
||||
}
|
||||
if app_state.replace(AppState::Game).is_err() {
|
||||
crate::levels::setup_level(&mut level_startup_event, &mut camera_query, &mut zoom_timer);
|
||||
crate::levels::setup_level(
|
||||
&mut level_startup_event,
|
||||
&mut camera_query,
|
||||
&mut zoom_timer,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue