wingbase/server/game/room/world/spawner.js
Asraelite bf8226481d add non-functioning explosions
I'm tired and box2d ray casting is stupid so this'll have to do for today
2016-03-25 00:54:15 +00:00

36 lines
666 B
JavaScript

'use strict';
const Asteroid = require('./asteroid.js');
const Missile = require('./missile.js');
class Spawner {
constructor(world) {
this.world = world;
}
spawnAsteroid(x, y, size) {
let pos = {
x: x,
y: y
};
let asteroid = new Asteroid(this.world, pos, size);
this.world.addAsteroid(asteroid);
}
spawnMissile(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.addMissile(missile);
}
}
module.exports = Spawner;