~comcloudway/little_town

448f6d37d801ed058043794647b995968bfaad8c — Jakob Meier 1 year, 9 months ago f4c477e
Added music fade-in
1 files changed, 8 insertions(+), 1 deletions(-)

M src/main.rs
M src/main.rs => src/main.rs +8 -1
@@ 36,9 36,10 @@ async fn main() {

    let mut ctx = AudioContext::new();
    let sound = Sound::load(&mut ctx, include_bytes!("../assets/music.wav"));
    let mut vol = 0.0;
    sound.play(&mut ctx, PlaySoundParams{
        looped: true,
        volume: 0.2
        volume: vol
    });

    loop {


@@ 46,6 47,12 @@ async fn main() {

        screen.draw(&assets).await;

        // fade in music
        if vol < 0.2 {
            vol += 0.001;
            sound.set_volume(&ctx, vol);
        }

        match screen.ev_loop() {
            GameEvent::Quit => break,
            GameEvent::ChangeScreen(s) => screen = s,