const mapWidth = 210.; const mapHeith = 100.; const playerSize = 10.; class Player { constructor (id,x,y,name) { this.name=name; this.x=x; this.y=y; this.id=id; this.visibleDir=1; this.dir=0;//0=standStill //1=North //2=North-East //3=East //4=South-East //5=South //6=South-West //7=West //8=North-West this.ammo=10; this.health=10; } takeDamage(amount) { this.health-=amount; if(this.health<=0) { //send death message to server //this.reset() } } get angle() { return (this.visibleDir-1)*3.1415926535/8.; } } function dist(A,B) { return sqrt((A.x-B.x)**2+(A.y-B.y)**2); } class Bullet { constructor (x,y,dx,dy) { this.x=x; this.y=y; this.dx=dx; this.dy=dy; this.deleted=false; } update() { if(!this.deleted) { this.x+=this.dx; this.y+=this.dy; } } checkCollisions(player,squares,circles)//only the client's player /!\ { if(!this.deleted) { if(dist(player,this)