rpjs/resources/sound_list.js
/**
     * Plays a sound where the volumn is attuned to
     * the distance from the camera sprite.
     */
Plays a sound where the volumn is attuned to
the distance from the camera sprite.
Plays a sound where the volumn is attuned to the distance from the camera sprite .
playAtSprite(name,sprite,cameraSprite)
    {
        let ctx=this.game.audioContext;
        let source,gain,vol;
        let x=sprite.x-cameraSprite.x;
        let y=sprite.y-cameraSprite.y;
        vol=this.MAIN_VOLUME-(Math.sqrt((x*x)+(y*y))*this.DISTANCE_ATTUATION);
        if (vol<=0.0) return;
        source=ctx.createBufferSource();
        gain=ctx.createGain();
        source.buffer=this.buffers.get(name);
        gain.gain.value=vol;
        source.connect(gain);
        gain.connect(ctx.destination);
        source.start(0);
    }
playAtSprite ( name , sprite , cameraSprite ) { let ctx = this . game . audioContext ; let source , gain , vol ; let x = sprite . x - cameraSprite . x ; let y = sprite . y - cameraSprite . y ; vol = this . MAIN_VOLUME - ( Math . sqrt ( ( x * x ) + ( y * y ) ) * this . DISTANCE_ATTUATION ) ; if ( vol <= 0.0 ) return ; source = ctx . createBufferSource ( ) ; gain = ctx . createGain ( ) ; source . buffer = this . buffers . get ( name ) ; gain . gain . value = vol ; source . connect ( gain ) ; gain . connect ( ctx . destination ) ; source . start ( 0 ) ; }
Plays a sound where the volumn is attuned to
 the distance from the camera sprite.
Plays a sound where the volumn is attuned to the distance from the camera sprite .
// attenuate, and if <= 0, don't play sound // play sound