diff --git a/src/utils/coordinates.ts b/src/utils/coordinates.ts index 17adc69..043f48a 100644 --- a/src/utils/coordinates.ts +++ b/src/utils/coordinates.ts @@ -1,5 +1,5 @@ import Phaser from 'phaser'; -import { SCALE } from '../config/constants'; +import { SCALE, RINK_WIDTH } from '../config/constants'; /** * Utility class for converting between game coordinates (meters) and screen coordinates (pixels) @@ -14,7 +14,8 @@ export class CoordinateUtils { */ static gameToScreen(scene: Phaser.Scene, gameX: number, gameY: number): { x: number; y: number } { const centerX = (scene.game.config.width as number) / 2; - const centerY = (scene.game.config.height as number) / 2; + // Center Y should be the center of the rink (not the full canvas including UI padding) + const centerY = (RINK_WIDTH * SCALE) / 2; return { x: centerX + gameX * SCALE, y: centerY - gameY * SCALE // Negative Y because screen coords increase downward @@ -30,7 +31,8 @@ export class CoordinateUtils { */ static screenToGame(scene: Phaser.Scene, screenX: number, screenY: number): { x: number; y: number } { const centerX = (scene.game.config.width as number) / 2; - const centerY = (scene.game.config.height as number) / 2; + // Center Y should be the center of the rink (not the full canvas including UI padding) + const centerY = (RINK_WIDTH * SCALE) / 2; return { x: (screenX - centerX) / SCALE, y: -(screenY - centerY) / SCALE // Negative Y to convert screen coords back to game coords