diff --git a/js/main.js b/js/main.js index 9db54ca..b2a6500 100644 --- a/js/main.js +++ b/js/main.js @@ -131,19 +131,30 @@ socket.on('replaceUtil', function (obj) { }); socket.on('hpChange', function (obj) { - console.log(obj); $(".hpBar").css({"width" : obj+"px"}); }); socket.on('newPlayerHp', function (obj) { - console.log(obj) + console.log(obj, obj.socketId, socket.id); if(obj.socketId == socket.id) { $(".hpBar").css({"width" : obj["hp"]+"px"}); + + if(obj.hp <=0) { + showDeathScreen() + } } }); +function showDeathScreen() { + socket.disconnect(); + $("body").empty(); + $("body").prepend(`
`); +} socket.on('dropItem', function (obj) { console.log(obj); @@ -190,8 +201,8 @@ socket.on('setpos', function (allPlayers) { if(id == socket.id) { let x = schatzCoords["x"]*32-allPlayers[id]["x"]+16; let y = schatzCoords["y"]*32-allPlayers[id]["y"]+16; - console.log(schatzCoords["x"]*32, schatzCoords["y"]*32) - console.log(allPlayers[id]["x"], allPlayers[id]["y"]) + // console.log(schatzCoords["x"]*32, schatzCoords["y"]*32) + // console.log(allPlayers[id]["x"], allPlayers[id]["y"]) let angle = calcAngleDegrees(x, y); $("#kompoassnadel").css("transform", "rotate(" + (angle+90) + "deg)"); diff --git a/server.js b/server.js index d246119..9f2632a 100644 --- a/server.js +++ b/server.js @@ -24,7 +24,7 @@ let schatzcoords = { x: 0, y: 0 }; while (!schatzversteckt) { for (var line = 0; line < newmap.cssMap.length; line++) { for (var column = 0; column < newmap.cssMap[line].length; column++) { - if (newmap.cssMap[line][column] == "grass") { //TODO schatz nicht im Wasser Spawnen! + if (newmap.cssMap[line][column] == "grass") { if (Math.random() < 0.1 && !schatzversteckt) { //console.log("versteckt", line, column) schatzcoords = { x: column, y: line };