From 077e58216c80aadd787113871ccf8e050d510a5a Mon Sep 17 00:00:00 2001 From: Thomas Richter Date: Thu, 5 Feb 2026 19:33:30 +0100 Subject: [PATCH] deploy: update image to latest --- src/scenes/DeepSeaHuntingScene.js | 45 ++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/src/scenes/DeepSeaHuntingScene.js b/src/scenes/DeepSeaHuntingScene.js index 0a77d19..5fc098b 100644 --- a/src/scenes/DeepSeaHuntingScene.js +++ b/src/scenes/DeepSeaHuntingScene.js @@ -140,13 +140,50 @@ export default class DeepSeaHuntingScene extends Phaser.Scene { ease: 'Sine.inOut' }); - // Move whale from entry to exit over 15 seconds + // Create curved path from entry to exit + const path = new Phaser.Curves.Path(entry.x, entry.y); + + // Calculate midpoint and perpendicular offset for curve + const midX = (entry.x + exit.x) / 2; + const midY = (entry.y + exit.y) / 2; + + // Create perpendicular offset for natural swimming curve + const dx = exit.x - entry.x; + const dy = exit.y - entry.y; + const dist = Math.sqrt(dx * dx + dy * dy); + + // Perpendicular direction (normalized) + const perpX = -dy / dist; + const perpY = dx / dist; + + // Random curve amplitude (positive or negative for variety) + const curveAmount = (Math.random() > 0.5 ? 1 : -1) * (80 + Math.random() * 120); + + // Control points for smooth S-curve + const ctrl1X = entry.x + dx * 0.25 + perpX * curveAmount; + const ctrl1Y = entry.y + dy * 0.25 + perpY * curveAmount; + const ctrl2X = entry.x + dx * 0.75 - perpX * curveAmount * 0.7; + const ctrl2Y = entry.y + dy * 0.75 - perpY * curveAmount * 0.7; + + // Add cubic bezier curve + path.cubicBezierTo(exit.x, exit.y, ctrl1X, ctrl1Y, ctrl2X, ctrl2Y); + + // Store path progress + const pathData = { t: 0 }; + + // Animate along curved path this.tweens.add({ - targets: whale, - x: exit.x, - y: exit.y, + targets: pathData, + t: 1, duration: 15000, ease: 'Sine.inOut', + onUpdate: () => { + const point = path.getPoint(pathData.t); + const tangent = path.getTangent(pathData.t); + + whale.setPosition(point.x, point.y); + whale.setRotation(Math.atan2(tangent.y, tangent.x)); + }, onComplete: () => { this.onWhaleExit(whale); }