Browse Source

"fixed" race condition, faster shooting

master
mort 8 years ago
parent
commit
f21b42068c
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      js/game.js

+ 5
- 3
js/game.js View File

@@ -146,7 +146,9 @@ class Player extends Entity {
id: this.id
});

game.entities.forEach((e) => e.send(true));
setTimeout(() => {
game.entities.forEach((e) => e.send(true));
}, 100);
} else if (req.url == "keydown") {
this.keys[req.data.key] = true;
} else if (req.url == "keyup") {
@@ -194,7 +196,7 @@ class Player extends Entity {
let b = new Bullet(pos, vel, this.id, this.game.id, this.game);
this.game.spawn(b);
this.canShoot = false;
setTimeout(() => this.canShoot = true, 300);
setTimeout(() => this.canShoot = true, 100);
}

f.rotate(this.rot);
@@ -296,7 +298,7 @@ export default class Game {
this.prevTime = null;

this.updateInterval = 1000/30;
this.sendInterval = 1000/15;
this.sendInterval = 1000/20;
this.dt = 0;

this.id = 1;

Loading…
Cancel
Save