Merge branch 'dev' of https://git.etud.insa-toulouse.fr/rebillar/GrandTabernacleAutoVI into dev
This commit is contained in:
		
						commit
						7b7da9b4eb
					
				
					 4 changed files with 12 additions and 10 deletions
				
			
		|  | @ -32,11 +32,6 @@ class Player | ||||||
|     takeDamage(amount) |     takeDamage(amount) | ||||||
|     { |     { | ||||||
|         this.health-=amount; |         this.health-=amount; | ||||||
|         if(this.health<=0) |  | ||||||
|         { |  | ||||||
|             //send death message to server
 |  | ||||||
|             //this.reset()
 |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     retrieveServerInfo(id,x,y,dir) |     retrieveServerInfo(id,x,y,dir) | ||||||
|  |  | ||||||
							
								
								
									
										12
									
								
								js/game.js
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								js/game.js
									
									
									
									
									
								
							|  | @ -133,10 +133,14 @@ function game() { | ||||||
| 		remPlayers(); | 		remPlayers(); | ||||||
| 		addBullets(); | 		addBullets(); | ||||||
| 		player.update(squares, circles, dt); | 		player.update(squares, circles, dt); | ||||||
| 
 | 		if(player.health <= 0) | ||||||
| 		players.forEach((p) => { | 		{ | ||||||
| 			p.update(squares, circles, dt); | 			Net.died(player.id); | ||||||
| 		}); | 			player.health=10; | ||||||
|  | 		} | ||||||
|  | 		for (var i = players.length - 1; i >= 0; i--) { | ||||||
|  | 			players[i].update(squares, circles, dt); | ||||||
|  | 		} | ||||||
| 		Renderer.ReloadAff(); | 		Renderer.ReloadAff(); | ||||||
| 		updateBullets(dt); | 		updateBullets(dt); | ||||||
| 		LB.ReloadAff(players, player); | 		LB.ReloadAff(players, player); | ||||||
|  |  | ||||||
|  | @ -52,6 +52,10 @@ class Network{ | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	die(id_){ | ||||||
|  | 		this.socket.send(JSON.stringify({type:"died",data:{id:id_}})); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	update(obj){ 		//send data to server in order to broadcast
 | 	update(obj){ 		//send data to server in order to broadcast
 | ||||||
| 		this.socket.send(JSON.stringify({ | 		this.socket.send(JSON.stringify({ | ||||||
| 			type: "update", | 			type: "update", | ||||||
|  |  | ||||||
|  | @ -122,7 +122,6 @@ wss.on('connection', (socket, req) => { | ||||||
|       broadcast(JSON.stringify(message), socket.id); |       broadcast(JSON.stringify(message), socket.id); | ||||||
| 
 | 
 | ||||||
|     } else if(message.type=="died"){ |     } else if(message.type=="died"){ | ||||||
| 
 |  | ||||||
|       broadcast(JSON.stringify(message), socket.id); |       broadcast(JSON.stringify(message), socket.id); | ||||||
|       for (var i = players.length - 1; i >= 0; i--) { |       for (var i = players.length - 1; i >= 0; i--) { | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue