From 9f88b162ea63cf1ae9cdbbd3d4e6ceb9d25be473 Mon Sep 17 00:00:00 2001 From: Atsuyo-INSA Date: Wed, 13 Dec 2023 14:11:21 +0100 Subject: [PATCH] almost perfect --- public_html/js/game.js | 3 ++- public_html/js/global.js | 1 + public_html/js/input.js | 3 +-- public_html/js/network.js | 4 ++-- public_html/js/render.js | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/public_html/js/game.js b/public_html/js/game.js index 7f64be7..795a777 100644 --- a/public_html/js/game.js +++ b/public_html/js/game.js @@ -16,6 +16,7 @@ function game() { net.died(player.id,-1); player.z=-1; player.deaths++; + players[0].kill++; player.health=10; } }); @@ -36,4 +37,4 @@ function game() { net.connect(); //connect to server, create a player, and retrieve all players info -setInterval(game); \ No newline at end of file +setInterval(game,16); \ No newline at end of file diff --git a/public_html/js/global.js b/public_html/js/global.js index dbde358..d5065d6 100644 --- a/public_html/js/global.js +++ b/public_html/js/global.js @@ -21,6 +21,7 @@ let cars = [new Car(0, 0), new Car(0, 7), new Car(0, 15)]; +players.push(new Player(-1,-50,-50,-1,"VOITURES",0)); function updatePlayer(data) { diff --git a/public_html/js/input.js b/public_html/js/input.js index 62f989a..3cf643a 100644 --- a/public_html/js/input.js +++ b/public_html/js/input.js @@ -22,8 +22,7 @@ class Input { let b = new Bullet(player.x,player.y,player.z,dx/norm,dy/norm,player.id); bullets.push(b); - - net.newBullet(b.x,b.y,b.z,b.dx,b.dy,b.parentId); + net.newBullet(b.x,b.y,b.z,b.dx,b.dy,b.shooterId); }); window.addEventListener("keydown", (e)=>{ diff --git a/public_html/js/network.js b/public_html/js/network.js index 0cd871f..3995631 100644 --- a/public_html/js/network.js +++ b/public_html/js/network.js @@ -31,10 +31,10 @@ class Network{ break; case "newBullet": - bullets.push(new Bullet(data.data.x,data.data.y,data.z,data.data.dx,data.data.dy,data.data.id, this.sound)); + bullets.push(new Bullet(data.data.x,data.data.y,data.data.z==undefined?0:data.data.z,data.data.dx,data.data.dy,data.data.id)); break; - case "died": + case "died": console.log("player",data.data.id,"was killed by",data.data.killerId); addKill(data.data.id,data.data.killerId); break; diff --git a/public_html/js/render.js b/public_html/js/render.js index 8989ece..e3de28f 100644 --- a/public_html/js/render.js +++ b/public_html/js/render.js @@ -87,7 +87,7 @@ class Render { ReloadAff() { let background; - if(player.z==0) + if(player.z<=0) { let date = new Date(); if(date.getMinutes()%10>=5){