pull/143/head
Aevann 2023-04-29 23:55:42 +02:00
parent de47c992fa
commit 0bf9e225f6
1 changed files with 20 additions and 22 deletions

View File

@ -1,8 +1,15 @@
const marsekoEl = document.getElementById("marseko");
let marsekoPosX = 32;
let marsekoPosY = 32;
let mousePosX = 0;
let mousePosY = 0;
function getRandomInt(max) {
return Math.max(32, Math.floor(Math.random() * max));
}
let marsekoPosX = getRandomInt(screen.availWidth/2);
let marsekoPosY = getRandomInt(screen.availHeight);
marsekoEl.style.left = `${marsekoPosX}px`;
marsekoEl.style.top = `${marsekoPosY}px`;
let mousePosX = marsekoPosX;
let mousePosY = marsekoPosY;
let frameCount = 0;
let idleTime = 0;
let idleAnimation = null;
@ -167,8 +174,8 @@ function frame() {
marsekoPosX = Math.min(Math.max(16, marsekoPosX), window.innerWidth - 16);
marsekoPosY = Math.min(Math.max(16, marsekoPosY), window.innerHeight - 16);
marsekoEl.style.left = `${marsekoPosX - 16}px`;
marsekoEl.style.top = `${marsekoPosY - 16}px`;
marsekoEl.style.left = `${marsekoPosX}px`;
marsekoEl.style.top = `${marsekoPosY}px`;
}
document.onmousemove = (event) => {
@ -176,12 +183,3 @@ document.onmousemove = (event) => {
mousePosY = event.clientY;
};
window.marseykoInterval = setInterval(frame, 100);
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
const random_left = getRandomInt(screen.width)
const random_top = getRandomInt(screen.height)
marsekoEl.style.left = `${random_left}px`;
marsekoEl.style.top = `${random_top}px`;