Skip to content

Commit

Permalink
improve music
Browse files Browse the repository at this point in the history
  • Loading branch information
cstuncsik committed Jun 10, 2015
1 parent fe781db commit feded2a
Show file tree
Hide file tree
Showing 8 changed files with 981 additions and 1,165 deletions.
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"globals" : {
"game": true,
"jsfxr": true,
"Stats": true
"Stats": true,
"sonantx": true
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ You can try it [here](http://fewa.comformity.hu/)

**Game sound inspired by:** [@jackrugile](https://twitter.com/jackrugile) (http://codepen.io/jackrugile/blog/arcade-audio-for-js13k-games)

**Game music** Sonant-X (https://github.com/nicolas-van/sonant-x)
**Game music:** Sonant-X (https://github.com/nicolas-van/sonant-x) by nicolas-van

**Game random number utility inspired by:** # JS13KGames Boilerplate (https://github.com/ooflorent/js13k-boilerplate/blob/master/src/rng.js)

Expand Down
3 changes: 3 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ <h2>Credits</h2>
(<a href="http://codepen.io/jackrugile/blog/arcade-audio-for-js13k-games" target="_blank">http://codepen.io/jackrugile/blog/arcade-audio-for-js13k-games</a>)
</p>

<p>Game music: Sonant-X (<a href="https://github.com/nicolas-van/sonant-x" target="_blank">https://github.com/nicolas-van/sonant-x</a>) by @nicolas-van
</p>

<p>Game random number utility inspired by: # JS13KGames Boilerplate (<a
href="https://github.com/ooflorent/js13k-boilerplate/blob/master/src/rng.js" target="_blank">https://github.com/ooflorent/js13k-boilerplate/blob/master/src/rng.js</a>)
</p>
Expand Down
21 changes: 12 additions & 9 deletions app/scripts/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
},
mute: function () {
game.audio.mute = !game.audio.mute;
for (var track in game.music.pool) {
if (game.music.pool.hasOwnProperty(track)) {
var music = game.music.pool[track];
music.volume(game.audio.mute ? 0 : 0.4);
}
}
},
menu: function (resume) {
game.paused = true;
Expand Down Expand Up @@ -431,6 +437,12 @@
},
init: function () {

game.music.generate('main', function (music) {
music.loop = true;
music.volume(0.4);
music.start();
});

game.obj.extend(true, game, {
ww: window.innerWidth,
wh: window.innerHeight,
Expand Down Expand Up @@ -496,15 +508,6 @@
game.stats();
game.menu();

var audioCtx = new AudioContext();
var songGen = new sonantx.MusicGenerator(song);
songGen.createAudioBuffer(function(buffer) {
var source = audioCtx.createBufferSource(); // Create Sound Source
source.buffer = buffer; // Add Buffered Data to Object
source.connect(audioCtx.destination); // Connect Sound Source to Output
source.start();
});

}
});

Expand Down
Loading

0 comments on commit feded2a

Please sign in to comment.