From db16ec2a04edb53bdf0a57bb408384ac83e3206b Mon Sep 17 00:00:00 2001 From: Pierre Wessman <4029607+pierrewessman@users.noreply.github.com> Date: Thu, 2 Oct 2025 14:41:53 +0200 Subject: [PATCH] Add player collision with goal posts to prevent skating through goals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add physics colliders between all players and goal post structures - Players now collide with left/right posts and back bars of both goals - Prevents unrealistic behavior of skating through goal frames 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/game/GameScene.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/game/GameScene.ts b/src/game/GameScene.ts index e138b08..b44bba3 100644 --- a/src/game/GameScene.ts +++ b/src/game/GameScene.ts @@ -115,7 +115,7 @@ export class GameScene extends Phaser.Scene { private createPuck() { // Initialize puck at center ice (0, 0 in game coordinates) - this.puck = new Puck(this, 20, 5); + this.puck = new Puck(this, 27, 5); // Add collisions between puck and goal posts with custom bounce handler this.physics.add.collider(this.puck, this.leftGoal.getLeftPost(), this.handlePuckPostBounce, undefined, this); @@ -124,6 +124,16 @@ export class GameScene extends Phaser.Scene { this.physics.add.collider(this.puck, this.rightGoal.getLeftPost(), this.handlePuckPostBounce, undefined, this); this.physics.add.collider(this.puck, this.rightGoal.getRightPost(), this.handlePuckPostBounce, undefined, this); this.physics.add.collider(this.puck, this.rightGoal.getBackBar(), this.handlePuckPostBounce, undefined, this); + + // Add player collisions with goal posts (prevent skating through goals) + this.players.forEach(player => { + this.physics.add.collider(player, this.leftGoal.getLeftPost()); + this.physics.add.collider(player, this.leftGoal.getRightPost()); + this.physics.add.collider(player, this.leftGoal.getBackBar()); + this.physics.add.collider(player, this.rightGoal.getLeftPost()); + this.physics.add.collider(player, this.rightGoal.getRightPost()); + this.physics.add.collider(player, this.rightGoal.getBackBar()); + }); } private createGoals() {