update js

master
sundowndev 2017-12-09 06:28:16 +01:00
parent 8498dfef64
commit b6c7aca000
2 changed files with 19 additions and 3 deletions

View File

@ -254,6 +254,7 @@ function run (difficulty) {
gameover.style.display = 'block'; gameover.style.display = 'block';
playing = false; playing = false;
clearInterval(ntm); clearInterval(ntm);
nanoPlayer.pause();
} }
}, difficulty); }, difficulty);
@ -262,9 +263,10 @@ function run (difficulty) {
} }
var replay = document.querySelector('.replay'); var replay = document.querySelector('.replay');
var startmenu = document.querySelector('.startmenu');
var easy = document.querySelector('.play.easy'); var easy = document.querySelector('.play.easy');
var hard = document.querySelector('.play.hard'); var hard = document.querySelector('.play.hard');
var startmenu = document.querySelector('.startmenu'); var mute = document.querySelector('#mute');
replay.addEventListener('click', function(){ replay.addEventListener('click', function(){
run('easy'); run('easy');
@ -273,9 +275,23 @@ replay.addEventListener('click', function(){
easy.addEventListener('click', function(){ easy.addEventListener('click', function(){
run('easy'); run('easy');
startmenu.style.display = 'none'; startmenu.style.display = 'none';
nanoPlayer.play();
}); });
hard.addEventListener('click', function(){ hard.addEventListener('click', function(){
run('hard'); run('hard');
startmenu.style.display = 'none'; startmenu.style.display = 'none';
nanoPlayer.play();
});
mute.addEventListener('click', function(e){
var mute = document.querySelector('#mute');
if(mute.classList.contains('mute-off')){
mute.classList.remove('mute-off');
nanoPlayer.play();
}else{
mute.classList.add('mute-off');
nanoPlayer.pause();
}
}); });

View File

@ -30,7 +30,7 @@
<a href="#" class="play hard">Pas facile</a> <a href="#" class="play hard">Pas facile</a>
<img src="assets/img/tank.png" alt="tank"> <img src="assets/img/tank.png" alt="tank">
</div> </div>
<div id="mute" class="mute mute-off"></div> <div id="mute" class="mute"></div>
<div class="line line-1"> <div class="line line-1">
<div class="col col-1"></div> <div class="col col-1"></div>
<div class="col col-2"></div> <div class="col col-2"></div>
@ -261,7 +261,7 @@
<script> <script>
var nanoPlayer = new nanoPlayer('.nano-player', { var nanoPlayer = new nanoPlayer('.nano-player', {
// Parameters // Parameters
autoplay: true, autoplay: false,
loop: true, loop: true,
defaultVolume: 100, defaultVolume: 100,
songList: [ songList: [