From 86d3bb86d8c0ce739d323cba11d71aef32ebf3ca Mon Sep 17 00:00:00 2001 From: Atsuyo-INSA Date: Wed, 6 Dec 2023 10:40:08 +0100 Subject: [PATCH] Id in bullets --- js/class.js | 10 +++------- js/input.js | 4 ++-- js/network.js | 6 +++--- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/js/class.js b/js/class.js index c73dd75..5f1b4ab 100644 --- a/js/class.js +++ b/js/class.js @@ -103,20 +103,16 @@ class Player } } -function dist(A,B) -{ - return Math.sqrt((A.x-B.x)**2+(A.y-B.y)**2); -} - class Bullet { - constructor (x,y,dx,dy) + constructor (x,y,dx,dy,id) { this.x=x; this.y=y; this.dx=dx; this.dy=dy; this.deleted=false; + this.parentId=id; } update(dt) @@ -132,7 +128,7 @@ class Bullet { if(!this.deleted) { - if(player!=null && dist(player,this)