From 5e61e7b312b775c41c3a7d0539087a770f19792e Mon Sep 17 00:00:00 2001 From: leandro-rdz Date: Wed, 6 Dec 2023 08:58:18 +0100 Subject: [PATCH] Update inputs => mise en place arrow --- js/input.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/js/input.js b/js/input.js index 194dd25..0b232cb 100644 --- a/js/input.js +++ b/js/input.js @@ -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)