send player info
This commit is contained in:
		
							parent
							
								
									0f4d37f776
								
							
						
					
					
						commit
						a6a38acd08
					
				
					 2 changed files with 6 additions and 2 deletions
				
			
		|  | @ -7,7 +7,7 @@ let playerId = null; //id of client player | |||
| let players = []; | ||||
| let player = null; | ||||
| 
 | ||||
| Inp = new Input("canvas"); | ||||
| Inp = new Input("canvas", Net); | ||||
| 
 | ||||
| playerId=Net.playerId; | ||||
| player=Net.clientPlayer; | ||||
|  | @ -26,6 +26,7 @@ function game() { | |||
| 			//Inp.player=player; //pour connecter les input au joueur client
 | ||||
| 			console.log("Connected as id ",playerId); | ||||
| 			Inp.player=player; | ||||
| 			Renderer.AddPlayer(player) | ||||
| 		} | ||||
| 	} | ||||
| 	else | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| class Input { | ||||
|     constructor(id) { | ||||
|     constructor(id, net) { | ||||
|         this.keysDown = new Set() | ||||
|         this.dir = 0; | ||||
|         this.player=null; | ||||
|  | @ -8,6 +8,8 @@ class Input { | |||
|         this.mouseX = 0 | ||||
|         this.mouseY = 0 | ||||
| 
 | ||||
|         this.network = net | ||||
| 
 | ||||
|         // Event listener pour la position de la souris
 | ||||
|         this.canvas.addEventListener("mousemove", this.handleMouseMove.bind(this)) | ||||
| 
 | ||||
|  | @ -78,6 +80,7 @@ class Input { | |||
|         if(oldDir!=this.dir) | ||||
|         { | ||||
|             this.player.changeDirection(this.dir) | ||||
|             this.network.update(this.player) | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue