deathscreen

This commit is contained in:
Raphael 2025-02-13 13:37:46 +01:00
parent e4fb08e375
commit 342611819e
2 changed files with 16 additions and 5 deletions

View File

@ -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(`<div class="overlay" style="text-align: center; padding:100px; background: rgb(237 88 88 / 83%); width:800px; height:400px; border-radius:5px; z-index:2; margin-top:100px; margin-left:auto; margin-right:auto;">
<h1>Du bist gestorben!</h1>
<button style="font-size: 1.5em; background: #c7812b; border: 0; border-radius: 3px;" onclick="window.location.reload();">Neustart</button>
</div>`);
}
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)");

View File

@ -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 };