Quellcode durchsuchen

"fixed" race condition, faster shooting

master
mort vor 8 Jahren
Ursprung
Commit
f21b42068c
1 geänderte Dateien mit 5 neuen und 3 gelöschten Zeilen
  1. 5
    3
      js/game.js

+ 5
- 3
js/game.js Datei anzeigen

id: this.id id: this.id
}); });


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


f.rotate(this.rot); f.rotate(this.rot);
this.prevTime = null; this.prevTime = null;


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


this.id = 1; this.id = 1;

Laden…
Abbrechen
Speichern