function initTimer() {
  var TimerElem = document.querySelector(".timer_bar");
  TimerElem.style.width = "0%";
  let seconds = timeEnd;
  document.getElementById("timerend").innerHTML = " / "  + seconds + " s";
}

function move() {
  var lapsPerSecond = 100 / timeEnd;
  var TimerElem = document.querySelector(".timer_bar");
  TimerElem.style.width = (parseInt(TimerElem.style.width) + lapsPerSecond) + "%";
}



var timer = new easytimer.Timer();
timer.start();
timer.addEventListener('secondsUpdated', function (e) {
  if (timer.getTimeValues().seconds <= timeEnd) {
    document.getElementById("timer").innerHTML = timer.getTimeValues().seconds.toString() + " s";
    move();
  } else {
    timeTot = timeTot + timer.getTimeValues().seconds;
    endTime();
    timer.stop();
  }
});
function endTime() {
  if(!isTuto){
    document.querySelector("#mainPage").style.display = 'block';
  document.querySelector("#playPage").style.display = 'none';
  document.querySelector("#scoreTotGameOver").innerHTML = (niveauActuel * (50 / timeTot)).toFixed(2);
  document.querySelector("#niveauGameOver").innerHTML = niveauActuel;
  document.querySelector("#TempsTotGameOver").innerHTML = timeTot;
  openModal('gameOver');
  }
  
}