From 9755a4c2a7c8e84219dc283f34ba5be2d96b6d84 Mon Sep 17 00:00:00 2001 From: _N3m0 Date: Thu, 13 Jun 2024 01:27:33 +0200 Subject: [PATCH] dancing fish --- index.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.html b/index.html index 5233f96..30671a1 100644 --- a/index.html +++ b/index.html @@ -34,6 +34,8 @@ var poisson = poissons[poissons.length-1] poisson.style.top = coord_map.top; poisson.style.left = coord_map.left + (coord_map.width-poisson.getBoundingClientRect().width)*Math.random(); + poisson.setAttribute("pos", poisson.style.left.replace("px", "")); + poisson.setAttribute("i", 0); }, 1000); input.onkeyup = () => { @@ -52,6 +54,8 @@ var p = poissons[i]; var new_top = parseInt(p.style.top.replace("px", "")) + 10; p.style.top = new_top; + p.setAttribute("i", parseInt(p.getAttribute("i")) + 1); + p.style.left = parseInt(p.getAttribute('pos')) + Math.sin(parseInt(p.getAttribute('i')))*10; if (new_top > coord_map.height + coord_map.top - p.getBoundingClientRect().height) { p.remove(); }