From 57632a83e5b1fcca5a71643e82fde7e80cbf52f3 Mon Sep 17 00:00:00 2001 From: LoveEevee Date: Sat, 6 Oct 2018 10:23:36 +0300 Subject: [PATCH] Disable checking sound timer on touch devices --- public/src/js/game.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/public/src/js/game.js b/public/src/js/game.js index 1b0d657..b06ddd5 100644 --- a/public/src/js/game.js +++ b/public/src/js/game.js @@ -339,21 +339,23 @@ class Game{ this.started = true this.sndTime = this.startDate - snd.buffer.getTime() * 1000 }else if(ms < 0 || ms >= 0 && this.started){ - this.elapsedTime = this.getAccurateTime(ms >= 0) + var currentDate = +new Date + if(!this.controller.touchEnabled){ + var sndTime = currentDate - snd.buffer.getTime() * 1000 + var lag = sndTime - this.sndTime + if(Math.abs(lag) >= 50){ + this.startDate += lag + this.sndTime = sndTime + } + } + this.elapsedTime = currentDate - this.startDate } } getAccurateTime(){ if(this.isPaused()){ return this.elapsedTime }else{ - var currentDate = +new Date - var sndTime = currentDate - snd.buffer.getTime() * 1000 - var lag = sndTime - this.sndTime - if(Math.abs(lag) >= 50){ - this.startDate += lag - this.sndTime = sndTime - } - return currentDate - this.startDate + return (+new Date) - this.startDate } } getCircles(){