code cleaning
This commit is contained in:
parent
45902fd0f1
commit
7cd3c8e8dd
3 changed files with 6 additions and 1 deletions
|
@ -36,8 +36,9 @@ class Player
|
||||||
if(this.health<=0)
|
if(this.health<=0)
|
||||||
{
|
{
|
||||||
this.death++;
|
this.death++;
|
||||||
net.died(this.id,killerId);
|
|
||||||
this.health=defaulthealth;
|
this.health=defaulthealth;
|
||||||
|
|
||||||
|
net.died(this.id,killerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ function game() {
|
||||||
for (let i = 0;i<players.length; i++) {
|
for (let i = 0;i<players.length; i++) {
|
||||||
players[i].update(squares, circles, dt);
|
players[i].update(squares, circles, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
cars.forEach((c) => {
|
cars.forEach((c) => {
|
||||||
c.Update();
|
c.Update();
|
||||||
if(c.collide(player.x,player.y))
|
if(c.collide(player.x,player.y))
|
||||||
|
@ -40,6 +41,7 @@ function game() {
|
||||||
player.health=10;
|
player.health=10;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
updateBullets(dt);
|
updateBullets(dt);
|
||||||
renderer.ReloadAff();
|
renderer.ReloadAff();
|
||||||
LB.ReloadAff();
|
LB.ReloadAff();
|
||||||
|
|
|
@ -22,8 +22,10 @@ class Input {
|
||||||
let dy = mouseY-player.y;
|
let dy = mouseY-player.y;
|
||||||
|
|
||||||
let norm = Math.sqrt(dx*dx+dy*dy);
|
let norm = Math.sqrt(dx*dx+dy*dy);
|
||||||
|
|
||||||
let b = new Bullet(player.x,player.y,dx/norm,dy/norm,player.id);
|
let b = new Bullet(player.x,player.y,dx/norm,dy/norm,player.id);
|
||||||
bullets.push(b);
|
bullets.push(b);
|
||||||
|
|
||||||
net.newBullet(b.x,b.y,b.dx,b.dy,b.parentId);
|
net.newBullet(b.x,b.y,b.dx,b.dy,b.parentId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue