-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9260e93
commit 71d6bff
Showing
5 changed files
with
83 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Credits | ||
|
||
## Audio | ||
|
||
- [explosion.ogg](https://freesound.org/people/Werra/sounds/244394/) - edited |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use bevy::prelude::*; | ||
use bevy_cameraman::Cameraman; | ||
|
||
const DEBUG: bool = false; | ||
|
||
pub struct AudioPlugin; | ||
|
||
impl Plugin for AudioPlugin { | ||
fn build(&self, app: &mut App) { | ||
app.add_systems(PostStartup, setup); | ||
} | ||
} | ||
|
||
fn setup(mut commands: Commands, query_camera: Query<Entity, With<Cameraman>>) { | ||
let gap = 200.; | ||
let listener = SpatialListener::new(gap); | ||
|
||
for entity in &query_camera { | ||
let mut cmd = commands.entity(entity); | ||
let cmd = cmd.insert((SpatialBundle::default(), listener.clone())); | ||
|
||
if DEBUG { | ||
cmd.with_children(|parent| { | ||
// left ear | ||
parent.spawn(SpriteBundle { | ||
sprite: Sprite { | ||
color: Color::RED, | ||
custom_size: Some(Vec2::splat(20.0)), | ||
..default() | ||
}, | ||
transform: Transform::from_xyz(-gap / 2.0, 0.0, 0.0), | ||
..default() | ||
}); | ||
|
||
// right ear | ||
parent.spawn(SpriteBundle { | ||
sprite: Sprite { | ||
color: Color::GREEN, | ||
custom_size: Some(Vec2::splat(20.0)), | ||
..default() | ||
}, | ||
transform: Transform::from_xyz(gap / 2.0, 0.0, 0.0), | ||
..default() | ||
}); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters