Add positional sounds from the tilemap

This commit is contained in:
2014-06-14 00:00:17 -07:00
parent 3059e1b192
commit 426915e0e2

View File

@@ -121,13 +121,13 @@ SoundSprite.prototype.adjust_relative_to = function(spr) {
if ( yd < 0 )
yd = -(yd);
var hyp = Math.sqrt((xd * xd) + (yd * yd));
var hyp = Math.sqrt(Number(xd * xd) + Number(yd * yd));
var hyp_perfect = Math.sqrt(
Number((game.camera.width/2) * (game.camera.width/2)) +
Number((game.camera.height/2) * (game.camera.height/2))
);
this.sound.volume = 1.0 - Math.max(1.0, Number(hyp / hyp_perfect));
this.sound.volume = Number(hyp / hyp_perfect);
console.log([hyp_perfect, hyp, Number(hyp / hyp_perfect), this.sound.volume]);
}