death
This commit is contained in:
		
							parent
							
								
									25a350e1e5
								
							
						
					
					
						commit
						8c43c89991
					
				
					 3 changed files with 9 additions and 5 deletions
				
			
		|  | @ -29,11 +29,6 @@ class Player | |||
|     takeDamage(amount) | ||||
|     { | ||||
|         this.health-=amount; | ||||
|         if(this.health<=0) | ||||
|         { | ||||
|             //send death message to server
 | ||||
|             //this.reset()
 | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     retrieveServerInfo(id,x,y,dir) | ||||
|  |  | |||
|  | @ -131,6 +131,11 @@ function game() { | |||
| 		remPlayers(); | ||||
| 		addBullets(); | ||||
| 		player.update(squares, circles, dt); | ||||
| 		if(player.health <= 0) | ||||
| 		{ | ||||
| 			Net.died(player.id); | ||||
| 			player.health=10; | ||||
| 		} | ||||
| 		for (var i = players.length - 1; i >= 0; i--) { | ||||
| 			players[i].update(squares, circles, dt); | ||||
| 		} | ||||
|  |  | |||
|  | @ -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
 | ||||
| 		this.socket.send(JSON.stringify({ | ||||
| 			type: "update", | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue