diff --git a/js/class.js b/js/class.js index 0b3a632..e95eece 100644 --- a/js/class.js +++ b/js/class.js @@ -4,7 +4,7 @@ const playerSize = 50.; const playerSpeed=.2; const bulletSpeed=playerSpeed*2; const halfSqrtTwo=0.70710678118; -const defaulthealth=10 +const defaulthealth=10.; class Player { diff --git a/js/game.js b/js/game.js index efdfb79..222a68e 100644 --- a/js/game.js +++ b/js/game.js @@ -108,6 +108,7 @@ function game() { player=Net.clientPlayer; players=Net.getPlayersToAdd(); Renderer.AddPlayer(player) + Renderer.SetPlayerId(player.id) console.log("Connected as id ",playerId); Inp.player=player; diff --git a/js/render.js b/js/render.js index f54971e..f3ae805 100644 --- a/js/render.js +++ b/js/render.js @@ -11,6 +11,11 @@ class Render { this.bullets = []; this.mapsrc=mapsrc; this.ReloadAff(); + this.playerid=0; + } + + SetPlayerId(id) { + this.playerid=id } AddPlayer(player) { @@ -49,6 +54,12 @@ class Render { this.ctx.fillStyle = 'white'; this.ctx.font="10pt arial"; this.ctx.fillText(player.name,player.x-player.name.length*10/3,player.y-playerSize/1.8); + if(player.id==this.playerid) { + this.ctx.fillStyle = 'red'; + this.ctx.fillRect(player.x-playerSize/2-5, player.y-playerSize/2, playerSize+10, 5); + this.ctx.fillStyle = '#7AFF33'; + this.ctx.fillRect(player.x-playerSize/2-5, player.y-playerSize/2, player.health*(playerSize+10)/defaulthealth, 5); + } } RenderBullet(bullet) {