less calls to update timer
This commit is contained in:
parent
146aaf867e
commit
0164d197e1
1 changed files with 7 additions and 4 deletions
11
game/game.js
11
game/game.js
|
|
@ -207,10 +207,9 @@ function addMenuToDom(gameId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const timerCountdownEl = ELEMENTS.DIV.cloneNode(true)
|
const timerCountdownEl = ELEMENTS.DIV.cloneNode(true)
|
||||||
timerCountdownEl.innerText = timerStr()
|
const updateTimer = () => {
|
||||||
setInterval(() => {
|
|
||||||
timerCountdownEl.innerText = timerStr()
|
timerCountdownEl.innerText = timerStr()
|
||||||
}, 50) // needs to be small, so that it updates quick enough in replay
|
}
|
||||||
|
|
||||||
const timerEl = ELEMENTS.DIV.cloneNode(true)
|
const timerEl = ELEMENTS.DIV.cloneNode(true)
|
||||||
timerEl.classList.add('timer')
|
timerEl.classList.add('timer')
|
||||||
|
|
@ -247,6 +246,7 @@ function addMenuToDom(gameId) {
|
||||||
playerColorPickerEl,
|
playerColorPickerEl,
|
||||||
nameChangeEl,
|
nameChangeEl,
|
||||||
updateScoreBoard,
|
updateScoreBoard,
|
||||||
|
updateTimer,
|
||||||
replayControl,
|
replayControl,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -383,7 +383,8 @@ async function main() {
|
||||||
|
|
||||||
const bitmaps = await PuzzleGraphics.loadPuzzleBitmaps(Game.getPuzzle(gameId))
|
const bitmaps = await PuzzleGraphics.loadPuzzleBitmaps(Game.getPuzzle(gameId))
|
||||||
|
|
||||||
const {bgColorPickerEl, playerColorPickerEl, nameChangeEl, updateScoreBoard, replayControl} = addMenuToDom(gameId)
|
const {bgColorPickerEl, playerColorPickerEl, nameChangeEl, updateScoreBoard, updateTimer, replayControl} = addMenuToDom(gameId)
|
||||||
|
updateTimer()
|
||||||
updateScoreBoard(TIME())
|
updateScoreBoard(TIME())
|
||||||
|
|
||||||
const longFinished = !! Game.getFinishTs(gameId)
|
const longFinished = !! Game.getFinishTs(gameId)
|
||||||
|
|
@ -441,6 +442,7 @@ async function main() {
|
||||||
localStorage.setItem('player_name', nameChangeEl.value)
|
localStorage.setItem('player_name', nameChangeEl.value)
|
||||||
evts.addEvent([Protocol.INPUT_EV_PLAYER_NAME, nameChangeEl.value])
|
evts.addEvent([Protocol.INPUT_EV_PLAYER_NAME, nameChangeEl.value])
|
||||||
})
|
})
|
||||||
|
setInterval(updateTimer, 1000)
|
||||||
} else if (MODE === 'replay') {
|
} else if (MODE === 'replay') {
|
||||||
const setSpeedStatus = () => {
|
const setSpeedStatus = () => {
|
||||||
replayControl.speed.innerText = 'Replay-Speed: ' +
|
replayControl.speed.innerText = 'Replay-Speed: ' +
|
||||||
|
|
@ -540,6 +542,7 @@ async function main() {
|
||||||
} while (true)
|
} while (true)
|
||||||
REPLAY.lastRealTs = realTs
|
REPLAY.lastRealTs = realTs
|
||||||
REPLAY.lastGameTs = maxGameTs
|
REPLAY.lastGameTs = maxGameTs
|
||||||
|
updateTimer()
|
||||||
}, 50)
|
}, 50)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue