Update inputs => mise en place arrow

This commit is contained in:
leandro-rdz 2023-12-06 08:58:18 +01:00
parent bd1768203d
commit 5e61e7b312

View file

@ -17,7 +17,7 @@ class Input {
console.log("Clic de la souris");
});
/*window.addEventListener("keydown", function(event) {
window.addEventListener("keydown", function(event) {
switch(event.key) {
case "ArrowUp":
console.log("Flèche du haut");
@ -32,7 +32,7 @@ class Input {
console.log("Flèche de droite pressée");
break;
}
});*/
});
window.addEventListener("keydown", (e)=>{
this.keysDown.add(e.key.toLowerCase())
@ -50,31 +50,31 @@ class Input {
return;
let oldDir=this.dir;
this.dir=0;
if(this.keysDown.has('z')){
if(this.keysDown.has('d')){
if(this.keysDown.has('z') || this.keysDown.has('arrowup')){
if(this.keysDown.has('d') || this.keysDown.has('arrowright')){
this.dir = 2;
}else if(this.keysDown.has('s')){
}else if(this.keysDown.has('s') || this.keysDown.has('arrowdown')){
this.dir = 0;
}else if(this.keysDown.has('q')){
}else if(this.keysDown.has('q') || this.keysDown.has('arrowleft')){
this.dir = 8;
}else{
this.dir = 1;
}
}else if(this.keysDown.has('d')){
if(this.keysDown.has('s')){
}else if(this.keysDown.has('d') || this.keysDown.has('arrowright')){
if(this.keysDown.has('s') || this.keysDown.has('arrowdown')){
this.dir = 4;
}else if(this.keysDown.has('q')){
}else if(this.keysDown.has('q') || this.keysDown.has('arrowleft')){
this.dir = 0;
}else{
this.dir = 3;
}
}else if(this.keysDown.has('s')){
if(this.keysDown.has('q')){
}else if(this.keysDown.has('s') || this.keysDown.has('arrowdown')){
if(this.keysDown.has('q') || this.keysDown.has('arrowLeft')){
this.dir = 6;
}else{
this.dir = 5;
}
}else if(this.keysDown.has('q')){
}else if(this.keysDown.has('q') || this.keysDown.has('arrowleft')){
this.dir = 7;
}
if(oldDir!=this.dir)