Update inputs => mise en place arrow
This commit is contained in:
		
							parent
							
								
									bd1768203d
								
							
						
					
					
						commit
						5e61e7b312
					
				
					 1 changed files with 12 additions and 12 deletions
				
			
		
							
								
								
									
										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) | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue