diff --git a/src/config/constants.ts b/src/config/constants.ts index d20c304..5b4984a 100644 --- a/src/config/constants.ts +++ b/src/config/constants.ts @@ -38,6 +38,7 @@ export const GOAL_DECELERATION_RATE = 0.9; // Speed multiplier reduction after g export const MOVEMENT_STOP_THRESHOLD = 0.1; // meters - stop moving when this close to target // Puck constants +export const PUCK_RADIUS = 0.2; // meters (regulation hockey puck is ~7.6cm diameter, make it larger to be visible) export const PUCK_PICKUP_RADIUS = 1.5; // meters export const PUCK_CARRY_DISTANCE = 1.0; // meters in front of player export const MAX_PUCK_VELOCITY = 50; // m/s diff --git a/src/entities/Puck.ts b/src/entities/Puck.ts index d8be0c5..7dd9ec8 100644 --- a/src/entities/Puck.ts +++ b/src/entities/Puck.ts @@ -1,5 +1,5 @@ import Phaser from 'phaser'; -import { SCALE, MAX_PUCK_VELOCITY } from '../config/constants'; +import { SCALE, MAX_PUCK_VELOCITY, PUCK_RADIUS } from '../config/constants'; import { CoordinateUtils } from '../utils/coordinates'; import type { PuckState, TeamSide, Position } from '../types/game'; @@ -33,9 +33,10 @@ export class Puck extends Phaser.GameObjects.Container { this.body = this.body as Phaser.Physics.Arcade.Body; - // Set physics body size to match the puck visual (10px diameter) - this.body.setSize(10, 10); - this.body.setOffset(-5, -5); // Center the body on the container + // Set physics body size to match the puck visual (scaled from meters) + const puckDiameter = PUCK_RADIUS * 2 * SCALE; + this.body.setSize(puckDiameter, puckDiameter); + this.body.setOffset(-puckDiameter / 2, -puckDiameter / 2); // Center the body on the container // Set max velocity (allow up to x m/s) this.body.setMaxVelocity(MAX_PUCK_VELOCITY * SCALE, MAX_PUCK_VELOCITY * SCALE); @@ -48,21 +49,22 @@ export class Puck extends Phaser.GameObjects.Container { this.body.setCollideWorldBounds(true); // Enable high-velocity collision detection - this.body.setCircle(5); // Use circular body instead of rectangle for better collision + this.body.setCircle(PUCK_RADIUS * SCALE); // Use circular body instead of rectangle for better collision this.createSprite(); } private createSprite() { const graphics = this.scene.add.graphics(); + const puckRadius = PUCK_RADIUS * SCALE; - // Draw puck as black circle (5px radius) + // Draw puck as black circle graphics.fillStyle(0x000000, 1); - graphics.fillCircle(0, 0, 5); + graphics.fillCircle(0, 0, puckRadius); // Add white highlight for visibility on ice graphics.fillStyle(0xffffff, 0.3); - graphics.fillCircle(-1, -1, 2); + graphics.fillCircle(-puckRadius / 2, -puckRadius / 2, puckRadius / 2); this.add(graphics); }