reduce update packets sent
This commit is contained in:
parent
d6daed2e9b
commit
ef2d067b38
15 changed files with 67 additions and 14 deletions
|
@ -3,6 +3,7 @@
|
|||
const Asteroid = require('./body/asteroid.js');
|
||||
const Grapple = require('./body/projectile/grapple.js');
|
||||
const Missile = require('./body/projectile/missile.js');
|
||||
const Laser = require('./body/turret/shot/laser.js');
|
||||
|
||||
class Spawner {
|
||||
constructor(world) {
|
||||
|
@ -51,6 +52,22 @@ class Spawner {
|
|||
this.world.addProjectile(grapple);
|
||||
return grapple;
|
||||
}
|
||||
|
||||
spawnLaser(ship) {
|
||||
let r = ship.pos.r;
|
||||
let ox = Math.cos(r) * 0.7;
|
||||
let oy = Math.sin(r) * 0.7;
|
||||
let pos = {
|
||||
x: ship.center.x + ox,
|
||||
y: ship.center.y + oy,
|
||||
r: r,
|
||||
xvel: ship.vel.x,
|
||||
yvel: ship.vel.y
|
||||
};
|
||||
let missile = new Missile(this.world, pos, ship);
|
||||
this.world.addProjectile(missile);
|
||||
return missile;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Spawner;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue