dancing fish
This commit is contained in:
parent
b909af11f6
commit
9755a4c2a7
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue