add dead state

This commit is contained in:
2025-01-13 14:08:10 +09:00
parent 03bbea4862
commit 16429a6e1b
4 changed files with 139 additions and 116 deletions
+6 -7
View File
@@ -8,8 +8,7 @@ export default class Game {
currentTick = 0
width = 2000
height = 2000
running = false
nextTick = 0
nextTickAt = 0
#logic = null
#entities = []
@@ -88,15 +87,15 @@ export default class Game {
gameLoop() {
const tickBudget = this.#tickBudget
if (this.nextTick != null) {
const nextTick = this.nextTick
this.nextTick = null
if (this.nextTickAt != null) {
const nextTickAt = this.nextTickAt
this.nextTickAt = null
let start = performance.now()
while (start < nextTick) { start = performance.now() }
while (start < nextTickAt) { start = performance.now() }
this.update()
this.nextTick = start + tickBudget
this.nextTickAt = start + tickBudget
}
}