diff --git a/examples/hello_sound.rs b/examples/hello_sound.rs new file mode 100644 index 0000000..791e89d --- /dev/null +++ b/examples/hello_sound.rs @@ -0,0 +1,23 @@ +use comet::prelude::*; + +fn setup(app: &mut App, _renderer: &mut Renderer2D) { + app.load_audio("startup", "res/sounds/hit.ogg"); + app.play_audio("startup", true); // second parameter loops the sound + + // here the float indicated the volume percentage + // in the standard backend for audio in comet (kira) 0.0 is equal to -20dB and 1.0 to 0dB + app.set_volume("startup", 1.0); +} + +#[allow(unused_variables)] +fn update(app: &mut App, renderer: &mut Renderer2D, dt: f32) { + // in this example, update_audio doesnt do anything because the kira audio system + // doesnt need any update + app.update_audio(dt); +} + +fn main() { + App::new() + .with_title("Comet Audio Example") + .run::(setup, update); +} diff --git a/res/sounds/hit.ogg b/res/sounds/hit.ogg new file mode 100644 index 0000000..a5cd995 Binary files /dev/null and b/res/sounds/hit.ogg differ