This commit is contained in:
2024-06-18 17:10:31 +01:00
commit 694571a3db
54 changed files with 2765 additions and 0 deletions

33
public/js/mob.js Normal file
View File

@@ -0,0 +1,33 @@
const monster = document.getElementById('monster')
let x = window.innerWidth / 2
let y = window.innerHeight / 2
let dx = 2.5
let dy = 2.5
function init(){
monster.style.top = + "px"
monster.style.left = window.innerWidth / 2 + "px"
movement()
}
function movement(){
if( x > window.innerWidth - 100 || x <= 0 ){
dx *= -1;
}
if( y > (window.innerHeight - 100) || y <= 100 ){
dy *= -1;
}
x += dx
y += dy
monster.style.top = y + "px"
monster.style.left = x + "px"
requestAnimationFrame(movement)
}
init()