adding responsive

This commit is contained in:
Killian Marty 2023-12-09 13:19:04 +01:00
parent 491195e7d3
commit bd2195de5f

View file

@ -10,8 +10,10 @@ class Input {
return;
}
let mouseX = e.clientX - this.canvas.getBoundingClientRect().left;
let mouseY = e.clientY - this.canvas.getBoundingClientRect().top;
let bounds = this.canvas.getBoundingClientRect();
let mouseX = (e.clientX - bounds.x)*this.canvas.width/bounds.width;
let mouseY = (e.clientY - bounds.y)*this.canvas.height/bounds.height;
if(player.x>=2000 && player.y>=2000) {
mouseX+=2000;