Make crosshair shake smooth with oscillation

- Replaced random shake with smooth sine/cosine oscillation
- Added crosshairShakeTime variable to track oscillation phase
- Uses different frequencies (3x and 2.5x) for natural circular motion
- Creates predictable, smooth shake pattern instead of jittery random
- More comfortable aiming experience while maintaining difficulty

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Thomas Richter
2025-12-15 04:01:38 +01:00
parent 68ddb1aef7
commit 9b5f566bce

View File

@@ -14,6 +14,7 @@ export default class HuntingScene extends Phaser.Scene {
this.crosshairY = 300; this.crosshairY = 300;
this.crosshairSpeed = 5; this.crosshairSpeed = 5;
this.crosshairShakeAmount = 2; // Pixels of shake this.crosshairShakeAmount = 2; // Pixels of shake
this.crosshairShakeTime = 0; // Timer for smooth shake oscillation
this.useKeyboard = false; // Toggle between mouse and keyboard this.useKeyboard = false; // Toggle between mouse and keyboard
} }
@@ -48,9 +49,10 @@ export default class HuntingScene extends Phaser.Scene {
this.updateCrosshairMouse(); this.updateCrosshairMouse();
} }
// Update crosshair sprite position with shake // Update crosshair sprite position with smooth shake
const shakeX = (Math.random() - 0.5) * this.crosshairShakeAmount * 2; this.crosshairShakeTime += 0.15; // Increment for smooth oscillation
const shakeY = (Math.random() - 0.5) * this.crosshairShakeAmount * 2; const shakeX = Math.sin(this.crosshairShakeTime * 3) * this.crosshairShakeAmount;
const shakeY = Math.cos(this.crosshairShakeTime * 2.5) * this.crosshairShakeAmount;
this.crosshair.setPosition(this.crosshairX + shakeX, this.crosshairY + shakeY); this.crosshair.setPosition(this.crosshairX + shakeX, this.crosshairY + shakeY);
// Update harpoons // Update harpoons