diff --git a/src/config/constants.ts b/src/config/constants.ts index acc4664..d64fd63 100644 --- a/src/config/constants.ts +++ b/src/config/constants.ts @@ -46,6 +46,8 @@ 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 export const SHOT_SPEED = 30; // m/s +export const PUCK_DRAG = 200; // pixels/s² - ice friction (decelerates puck over time) +export const PUCK_BOUNCE = 0.6; // bounce coefficient (loses energy on wall/board collisions) // Puck reception constants export const PUCK_RECEPTION_BASE_CHANCE = 0.8; // Base chance to receive puck (modified by handling skill) diff --git a/src/entities/Puck.ts b/src/entities/Puck.ts index 7dd9ec8..8beefd7 100644 --- a/src/entities/Puck.ts +++ b/src/entities/Puck.ts @@ -1,5 +1,5 @@ import Phaser from 'phaser'; -import { SCALE, MAX_PUCK_VELOCITY, PUCK_RADIUS } from '../config/constants'; +import { SCALE, MAX_PUCK_VELOCITY, PUCK_RADIUS, PUCK_DRAG, PUCK_BOUNCE } from '../config/constants'; import { CoordinateUtils } from '../utils/coordinates'; import type { PuckState, TeamSide, Position } from '../types/game'; @@ -44,8 +44,11 @@ export class Puck extends Phaser.GameObjects.Container { // Set initial velocity to 0 (stationary) this.body.setVelocity(0, 0); - // Add bounce to keep it moving - this.body.setBounce(1, 1); + // Add drag to simulate ice friction (puck decelerates over time) + this.body.setDrag(PUCK_DRAG); + + // Add bounce with energy loss on collisions + this.body.setBounce(PUCK_BOUNCE); this.body.setCollideWorldBounds(true); // Enable high-velocity collision detection diff --git a/src/game/GameScene.ts b/src/game/GameScene.ts index 84c80d1..310ffad 100644 --- a/src/game/GameScene.ts +++ b/src/game/GameScene.ts @@ -165,7 +165,7 @@ export class GameScene extends Phaser.Scene { private createPuck() { // Initialize puck at center ice (0, 0 in game coordinates) - this.puck = new Puck(this, 27, 5); + this.puck = new Puck(this, 5, 0); // Add collisions between puck and all goal posts with custom bounce handler this.physics.add.collider(this.puck, this.goalPostsGroup, this.handlePuckPostBounce, undefined, this);