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