fix projectiles
This commit is contained in:
parent
0906441246
commit
4f42723f4a
7 changed files with 20 additions and 8 deletions
|
@ -14,6 +14,13 @@ class Body {
|
|||
this.type = 'body';
|
||||
this.b2body = false;
|
||||
|
||||
this.x = data.x || 0;
|
||||
this.y = data.y || 0;
|
||||
this.xvel = data.xvel || 0;
|
||||
this.yvel = data.yvel || 0;
|
||||
this.r = data.r || 0;
|
||||
this.rvel = data.rvel || 0;
|
||||
|
||||
this.mounts = data.mounts || [];
|
||||
this.health = data.health || 1;
|
||||
this.mounts = this.mounts.map(m => new Mount(this, m));
|
||||
|
@ -113,7 +120,7 @@ class Body {
|
|||
fixtures: this.mounts.map(m => m.packFull()),
|
||||
delta: this.packDelta(),
|
||||
interface: this.interface
|
||||
}
|
||||
};
|
||||
|
||||
let typePacket = this.packTypeFull();
|
||||
for (let i in typePacket)
|
||||
|
|
|
@ -5,9 +5,11 @@ const Rope = require('../../copula/rope.js');
|
|||
|
||||
class Grapple extends Projectile {
|
||||
constructor(world, pos, source) {
|
||||
// pos.x *= 32, pos.y *= 32, idk why
|
||||
super(world, pos);
|
||||
|
||||
this.r = pos.r;
|
||||
this.x = pos.x * 32;
|
||||
this.y = pos.y * 32;
|
||||
this.xvel += Math.cos(this.r) * 0.25;
|
||||
this.yvel += Math.sin(this.r) * 0.25;
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ const Body = require('../body.js');
|
|||
class Projectile extends Body {
|
||||
constructor(world) {
|
||||
super(world);
|
||||
|
||||
this.class = 'projectile';
|
||||
}
|
||||
|
||||
connect() {
|
||||
|
|
|
@ -75,6 +75,7 @@ class World {
|
|||
this.bodies.add(body);
|
||||
if (body.type == 'asteroid') this.asteroids.add(body);
|
||||
if (body.type == 'structure') this.structures.add(body);
|
||||
if (body.class == 'projectile') this.projectiles.add(body);
|
||||
this.physics.createBody(body);
|
||||
this.room.broadcast('create', body.packFull());
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ class Spawner {
|
|||
yvel: ship.vel.y
|
||||
};
|
||||
let missile = new Missile(this.world, pos, ship);
|
||||
this.world.addProjectile(missile);
|
||||
return missile;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue