add dead state
This commit is contained in:
+6
-7
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user