warn if tick or render takes to long

This commit is contained in:
Evan
2024-12-21 20:15:52 -08:00
parent 361b1f7d6c
commit 65ff9cfe19
2 changed files with 11 additions and 0 deletions
+6
View File
@@ -116,6 +116,7 @@ export class GameRenderer {
}
renderGame() {
const start = performance.now()
// Set background
this.context.fillStyle = this.game.config().theme().backgroundColor().toHex();
this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
@@ -140,6 +141,11 @@ export class GameRenderer {
})
requestAnimationFrame(() => this.renderGame());
const duration = performance.now() - start
if (duration > 10) {
console.warn(`tick ${this.game.ticks()} took ${duration}ms to render frame`)
}
}
tick() {