feat: Add F3 debug mode with collision boxes and FPS display
This commit is contained in:
@@ -203,6 +203,26 @@ class PhysicsObject {
|
||||
ctx.rotate(this.rotation);
|
||||
ctx.fillStyle = this.color;
|
||||
|
||||
// Draw collision box in debug mode
|
||||
if (debugMode) {
|
||||
ctx.strokeStyle = '#ff0000';
|
||||
ctx.lineWidth = 1;
|
||||
|
||||
// Draw a circle for the collision radius
|
||||
ctx.beginPath();
|
||||
ctx.arc(0, 0, this.size * PIXEL_SIZE / 2, 0, Math.PI * 2);
|
||||
ctx.stroke();
|
||||
|
||||
// Draw a dot at the center
|
||||
ctx.fillStyle = '#ffff00';
|
||||
ctx.beginPath();
|
||||
ctx.arc(0, 0, 2, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
|
||||
// Restore original fill color
|
||||
ctx.fillStyle = this.color;
|
||||
}
|
||||
|
||||
if (this.type === SQUARE) {
|
||||
const halfSize = this.size / 2 * PIXEL_SIZE;
|
||||
ctx.fillRect(-halfSize, -halfSize, this.size * PIXEL_SIZE, this.size * PIXEL_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user