One commited on
Commit
46f1ea1
·
verified ·
1 Parent(s): 1e318a4

Upload index.html

Browse files
Files changed (1) hide show
  1. index.html +28 -2
index.html CHANGED
@@ -22,7 +22,10 @@
22
  <script>
23
  (() => {
24
  "use strict";
25
- // ============ Aquarium v10 — bubble pops + per-fish early/normal/late sleep & wake ======
 
 
 
26
  const canvas = document.getElementById("tank");
27
  const ctx = canvas.getContext("2d");
28
  let W = 0, H = 0;
@@ -469,8 +472,31 @@ function buildScene() {
469
  rocks = [];
470
  sandHeights = [];
471
 
 
 
472
  const sandTop = H - Math.max(60, H * 0.12);
473
- for (let x = 0; x <= W + 40; x += 40) sandHeights.push(sandTop + rand(-8, 14));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
474
 
475
  // plants grow in bundles of stalks sharing a base patch; each stalk sprouts side branches
476
  const nClusters = Math.max(6, Math.floor(W / 150));
 
22
  <script>
23
  (() => {
24
  "use strict";
25
+ // ============ Aquarium v10 ALT — hilly terrain (alt) ================================
26
+ // Based on v10: same behavior, but the sand bed is generated as rolling hills that
27
+ // differ on every refresh. Fish skim over crests, and night-time sleep clusters form
28
+ // on the hilly seaweed/grass patches instead of a flat line.
29
  const canvas = document.getElementById("tank");
30
  const ctx = canvas.getContext("2d");
31
  let W = 0, H = 0;
 
472
  rocks = [];
473
  sandHeights = [];
474
 
475
+ // ALT: rolling hills instead of a flat bed — three octaves of random sine waves
476
+ // (broad swells + mid undulations + fine ripples), re-rolled on every refresh.
477
  const sandTop = H - Math.max(60, H * 0.12);
478
+ const hillUp = rand(34, 58); // tallest crest rises this far above the baseline
479
+ const hillDown = rand(14, 26); // deepest dip sinks this far below it
480
+ const waves = [
481
+ { wl: rand(380, 720), amp: 1.00, ph: rand(0, Math.PI * 2) }, // broad swells
482
+ { wl: rand(170, 320), amp: 0.45, ph: rand(0, Math.PI * 2) }, // mid undulations
483
+ { wl: rand(80, 150), amp: 0.18, ph: rand(0, Math.PI * 2) } // fine surface ripples
484
+ ];
485
+ const raw = [];
486
+ for (let x = 0; x <= W + 40; x += 40) {
487
+ let v = 0;
488
+ for (const wv of waves) v += Math.sin((x / wv.wl) * Math.PI * 2 + wv.ph) * wv.amp;
489
+ raw.push(v);
490
+ }
491
+ // Rescale so the extremes land exactly at the chosen limits — full relief, no clamping
492
+ let lo = Infinity, hi = -Infinity;
493
+ for (const v of raw) { if (v < lo) lo = v; if (v > hi) hi = v; }
494
+ const span = Math.max(0.001, hi - lo);
495
+ sandHeights.length = 0;
496
+ for (const v of raw) {
497
+ const off = -hillUp + ((hi - v) / span) * (hillUp + hillDown); // crest → -hillUp, dip → +hillDown
498
+ sandHeights.push(sandTop + off);
499
+ }
500
 
501
  // plants grow in bundles of stalks sharing a base patch; each stalk sprouts side branches
502
  const nClusters = Math.max(6, Math.floor(W / 150));