dancing fish

This commit is contained in:
_N3m0 2024-06-13 01:27:33 +02:00
parent b909af11f6
commit 9755a4c2a7
1 changed files with 4 additions and 0 deletions

View File

@ -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();
}