reduce update packets sent

This commit is contained in:
Asraelite 2016-03-30 12:50:59 +01:00
parent d6daed2e9b
commit ef2d067b38
15 changed files with 67 additions and 14 deletions

View file

@ -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;