One commited on
Commit
300ece8
·
verified ·
1 Parent(s): aaaabf9

Upload index.html

Browse files
Files changed (1) hide show
  1. index.html +7 -3
index.html CHANGED
@@ -278,6 +278,7 @@ class Fish {
278
  this.speedFactor = 1; // current speed multiplier (eased toward target)
279
  this.targetSpeedFactor = 1; // where speedFactor is easing toward
280
  this.cruiseSpeed = 1; // base cruising power (night lowers it, dusk eases it back)
 
281
 
282
  // Occasionally puffs a tiny cluster of bubbles from its mouth
283
  this.bubbleTimer = rand(4, 16); // seconds until the next bubble puff
@@ -476,11 +477,13 @@ class Fish {
476
  const playerSpeed = this.speed * this.cruiseSpeed * speedMult * 60 * dt;
477
  this.x += Math.cos(this.angle) * playerSpeed;
478
  this.y += Math.sin(this.angle) * playerSpeed;
 
479
  } else {
480
  // Normal AI fish movement.
481
  const sp = this.speed * this.cruiseSpeed * this.speedFactor * 60 * dt;
482
  this.x += Math.cos(this.angle) * sp;
483
  this.y += Math.sin(this.angle) * sp;
 
484
  }
485
 
486
  // NOTE: fish do NOT collide with plants — they plough straight through.
@@ -492,7 +495,8 @@ class Fish {
492
  this.y = Math.max(-50, Math.min(sandAt(this.x) - this.size * 0.35, this.y));
493
 
494
  // Tail beat follows actual speed — a resting fish barely moves its tail
495
- const effSpeed = this.speed * this.speedFactor;
 
496
  this.phase += dt * (4 + effSpeed * 3);
497
  }
498
  draw(c) {
@@ -1399,8 +1403,8 @@ function updatePlants(t, dt) {
1399
  // ---- fish push leaves aside: fish overpower the flora ----
1400
  for (const f of fishes) {
1401
  const R = 80, R2 = R * R; // influence radius around fish
1402
- const fSpd = f.speed * f.cruiseSpeed * f.speedFactor; // actual current speed
1403
- const fx = Math.cos(f.angle) * fSpd * 60; // fish velocity x (px/s)
1404
  const moveF = Math.min(1, fSpd / 1.2); // v9: how actively this fish is swimming
1405
  for (let i = 1; i <= w.segs; i++) {
1406
  const fl = i / w.segs;
 
278
  this.speedFactor = 1; // current speed multiplier (eased toward target)
279
  this.targetSpeedFactor = 1; // where speedFactor is easing toward
280
  this.cruiseSpeed = 1; // base cruising power (night lowers it, dusk eases it back)
281
+ this.currentVelocity = 0; // actual current velocity in px/s (for phase & collision)
282
 
283
  // Occasionally puffs a tiny cluster of bubbles from its mouth
284
  this.bubbleTimer = rand(4, 16); // seconds until the next bubble puff
 
477
  const playerSpeed = this.speed * this.cruiseSpeed * speedMult * 60 * dt;
478
  this.x += Math.cos(this.angle) * playerSpeed;
479
  this.y += Math.sin(this.angle) * playerSpeed;
480
+ this.currentVelocity = this.speed * this.cruiseSpeed * speedMult * 60; // track actual velocity
481
  } else {
482
  // Normal AI fish movement.
483
  const sp = this.speed * this.cruiseSpeed * this.speedFactor * 60 * dt;
484
  this.x += Math.cos(this.angle) * sp;
485
  this.y += Math.sin(this.angle) * sp;
486
+ this.currentVelocity = this.speed * this.cruiseSpeed * this.speedFactor * 60; // track actual velocity
487
  }
488
 
489
  // NOTE: fish do NOT collide with plants — they plough straight through.
 
495
  this.y = Math.max(-50, Math.min(sandAt(this.x) - this.size * 0.35, this.y));
496
 
497
  // Tail beat follows actual speed — a resting fish barely moves its tail
498
+ // Use the actual current velocity (which accounts for player boost/slow)
499
+ const effSpeed = this.currentVelocity / 60; // convert back to base units
500
  this.phase += dt * (4 + effSpeed * 3);
501
  }
502
  draw(c) {
 
1403
  // ---- fish push leaves aside: fish overpower the flora ----
1404
  for (const f of fishes) {
1405
  const R = 80, R2 = R * R; // influence radius around fish
1406
+ const fSpd = f.currentVelocity / 60; // actual current speed (from movement)
1407
+ const fx = Math.cos(f.angle) * f.currentVelocity; // fish velocity x (px/s)
1408
  const moveF = Math.min(1, fSpd / 1.2); // v9: how actively this fish is swimming
1409
  for (let i = 1; i <= w.segs; i++) {
1410
  const fl = i / w.segs;