even more audio fixes

This commit is contained in:
Bui 2018-08-06 12:04:02 +01:00
parent 90e461b587
commit 44c18c1ebc
6 changed files with 25 additions and 9 deletions

View File

@ -43,6 +43,8 @@ var assets = {
'cancel.wav', 'cancel.wav',
'results.wav', 'results.wav',
'note_don.ogg',
'note_ka.ogg',
'bgm_songsel.mp3', 'bgm_songsel.mp3',
'bgm_results.ogg' 'bgm_results.ogg'

View File

@ -22,11 +22,16 @@ function Controller(selectedSong, songData){
this.loadUIEvents = function(){ this.loadUIEvents = function(){
$("#song-selection-butt").click(function(){ $("#song-selection-butt").click(function(){
assets.sounds["don"].play();
_this.songSelection(); _this.songSelection();
}); });
$("#restart-butt").click(function(){ $("#restart-butt").click(function(){
assets.sounds["don"].play();
_this.restartSong(); _this.restartSong();
}); });
$("#continue-butt").click(function(){
_this.togglePauseMenu();
});
} }
this.startMainLoop = function(){ this.startMainLoop = function(){
@ -40,6 +45,7 @@ function Controller(selectedSong, songData){
_view.refresh(); _view.refresh();
} }
else if(ms>=0 && !started){ //when music shall starts else if(ms>=0 && !started){ //when music shall starts
assets.sounds["main-music"].volume = 0.7;
assets.sounds["main-music"].play(); assets.sounds["main-music"].play();
started=true; started=true;
} }

View File

@ -24,20 +24,20 @@ function Keyboard(controller){
this.checkGameKeys = function(){ this.checkGameKeys = function(){
if(_keys[86] && !_this.isWaitingForKeyup(86, "sound")){//if press v, play 'don' sound if(_keys[86] && !_this.isWaitingForKeyup(86, "sound")){//if press v, play 'don' sound
controller.playSound('don'); controller.playSound('note_don');
_this.waitForKeyup(86, "sound"); _this.waitForKeyup(86, "sound");
} }
if(_keys[66] && !_this.isWaitingForKeyup(66, "sound")){//if press b, play 'don' sound if(_keys[66] && !_this.isWaitingForKeyup(66, "sound")){//if press b, play 'don' sound
controller.playSound('don'); controller.playSound('note_don');
_this.waitForKeyup(66, "sound"); _this.waitForKeyup(66, "sound");
} }
if(_keys[67] && !_this.isWaitingForKeyup(67, "sound")){//if press c, play 'ka' sound if(_keys[67] && !_this.isWaitingForKeyup(67, "sound")){//if press c, play 'ka' sound
controller.playSound('ka'); controller.playSound('note_ka');
_this.waitForKeyup(67, "sound"); _this.waitForKeyup(67, "sound");
} }
if(_keys[78] && !_this.isWaitingForKeyup(78, "sound")){//if press n, play 'ka' sound if(_keys[78] && !_this.isWaitingForKeyup(78, "sound")){//if press n, play 'ka' sound
controller.playSound('ka'); controller.playSound('note_ka');
_this.waitForKeyup(78, "sound"); _this.waitForKeyup(78, "sound");
} }
@ -50,8 +50,8 @@ function Keyboard(controller){
controller.pauseSound("main-music", true); controller.pauseSound("main-music", true);
controller.songSelection(); controller.songSelection();
} }
if(_keys[27] && !_this.isWaitingForKeyup(27, "menu")){//if press escape key, pause the game if(_keys[81] && !_this.isWaitingForKeyup(81, "menu")){//if press p key, pause the game
_this.waitForKeyup(27, "menu"); _this.waitForKeyup(81, "menu");
controller.togglePauseMenu(); controller.togglePauseMenu();
} }

View File

@ -71,6 +71,7 @@ function Scoresheet(controller, score){
} }
this.run = function(){ this.run = function(){
assets.sounds["results"].volume = 0.6;
assets.sounds["results"].play(); assets.sounds["results"].play();
assets.sounds["bgm_results"].volume = 1; assets.sounds["bgm_results"].volume = 1;
@ -80,12 +81,14 @@ function Scoresheet(controller, score){
_this.setResults(); _this.setResults();
$("#song-select").click(function(){ $("#song-select").click(function(){
assets.sounds["don"].play();
assets.sounds["bgm_results"].pause(); assets.sounds["bgm_results"].pause();
assets.sounds["bgm_songsel"].currentTime = 0; assets.sounds["bgm_songsel"].currentTime = 0;
controller.songSelection(); controller.songSelection();
}); });
$("#replay").click(function(){ $("#replay").click(function(){
assets.sounds["don"].play();
assets.sounds["bgm_results"].pause(); assets.sounds["bgm_results"].pause();
assets.sounds["bgm_songsel"].currentTime = 0; assets.sounds["bgm_songsel"].currentTime = 0;
controller.restartSong(); controller.restartSong();

View File

@ -15,6 +15,7 @@ function SongSelect(){
$("#song-container").show(); $("#song-container").show();
$(".difficulty").click(function(e){ $(".difficulty").click(function(e){
assets.sounds["don"].play();
clearInterval(menuLoop); clearInterval(menuLoop);
var difficultyElement = (e.target.className=="stars" || e.target.className=="diffname") ? e.target.parentElement : e.target; var difficultyElement = (e.target.className=="stars" || e.target.className=="diffname") ? e.target.parentElement : e.target;
@ -37,8 +38,11 @@ function SongSelect(){
$(this).css("background", "rgba(255, 220, 47, 0.90)"); $(this).css("background", "rgba(255, 220, 47, 0.90)");
}); });
$(".song:not(.opened)").click(function(){ $(".song:not(.opened)").click(function(e){
assets.sounds["ka"].play(); if (!$(e.target).parents('.difficulties').length) {
assets.sounds["ka"].play();
};
$(".difficulty").hide(); $(".difficulty").hide();
$(".opened").removeClass("opened", 300); $(".opened").removeClass("opened", 300);
$(this).addClass("opened", 300, "linear", function(){ $(this).addClass("opened", 300, "linear", function(){

View File

@ -4,6 +4,7 @@
<div id='pause-menu'> <div id='pause-menu'>
<div class='window'> <div class='window'>
<button type='button' id='continue-butt'>Continue</button>
<button type='button' id='restart-butt'>Restart</button> <button type='button' id='restart-butt'>Restart</button>
<button type='button' id='song-selection-butt'>Song selection</button> <button type='button' id='song-selection-butt'>Song selection</button>
</div> </div>