feat: Add F3 debug mode with collision boxes and FPS display

This commit is contained in:
Kacper Kostka (aider)
2025-04-05 18:39:47 +02:00
parent cb62097150
commit 583544840b
4 changed files with 96 additions and 0 deletions

View File

@@ -62,6 +62,24 @@ class Entity {
);
}
// Draw collision box in debug mode
if (debugMode) {
ctx.strokeStyle = '#00ff00';
ctx.lineWidth = 1;
ctx.strokeRect(
-this.width/2 * PIXEL_SIZE,
-this.height/2 * PIXEL_SIZE,
this.width * PIXEL_SIZE,
this.height * PIXEL_SIZE
);
// Draw a dot at the entity's center
ctx.fillStyle = '#ffff00';
ctx.beginPath();
ctx.arc(0, 0, 2, 0, Math.PI * 2);
ctx.fill();
}
ctx.restore();
}