add ship destruction

This commit is contained in:
Asraelite 2016-03-30 19:58:56 +01:00
parent 44ddaacb15
commit d9e8e217c6
5 changed files with 47 additions and 12 deletions

View file

@ -4,6 +4,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/discharge/laser.js');
const Ship = require('./body/ship.js');
class Spawner {
constructor(world) {
@ -19,6 +20,17 @@ class Spawner {
this.world.addAsteroid(asteroid);
}
spawnShip(player) {
let pos = {
x: player.team == 'b' ? this.world.bounds.right - 5 : 5,
y: this.world.bounds.bottom / 2
};
let ship = new Ship(this.world, pos, player);
player.ship = ship;
this.world.addShip(ship);
}
spawnMissile(ship) {
let r = ship.pos.r;
let ox = Math.cos(r) * 0.7;