mirror of
https://github.com/Ellpeck/TinyLifeWeb.git
synced 2024-11-22 19:28:35 +01:00
18 lines
No EOL
466 B
JavaScript
18 lines
No EOL
466 B
JavaScript
let x = Math.random() * 100;
|
|
let y = Math.random() * 100;
|
|
|
|
let angle = Math.random() * 2 * Math.PI;
|
|
let addX = Math.cos(angle) * 0.02;
|
|
let addY = Math.sin(angle) * 0.02;
|
|
|
|
let background = $(".top");
|
|
background.css("background-position", `${x}% ${y}%`);
|
|
setInterval(function () {
|
|
x += addX;
|
|
y += addY;
|
|
if (x < 0 || x > 100)
|
|
addX *= -1;
|
|
if (y < 0 || y > 100)
|
|
addY *= -1;
|
|
background.css("background-position", `${x}% ${y}%`);
|
|
}, 30); |