Update inputs => mise en place arrow
這個提交存在於:
父節點
bd1768203d
當前提交
5e61e7b312
共有 1 個檔案被更改,包括 12 行新增 和 12 行删除
24
js/input.js
24
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)
|
||||
|
|
載入中…
新增問題並參考