add setname client command

This commit is contained in:
Asraelite 2016-03-28 15:10:20 +01:00
parent 52e1673e3e
commit 1af386d9f5
10 changed files with 50 additions and 11 deletions

View file

@ -19,7 +19,7 @@ class Connection {
});
socket.on('setName', data => {
this.player.name = data.name.slice(0, 20) || 'Fish';
this.player.name = ('' + data).slice(0, 20) || 'Fish';
});
socket.on('inputs', data => {

View file

@ -35,7 +35,7 @@ class Ship extends Body {
this.mounts.push(mount);
});
this.turrets = [];
this.turrets = build.turrets || [];
this.thrust = {
forward: 0,
@ -113,7 +113,7 @@ class Ship extends Body {
frame: this.frame,
power: this.power,
mounts: this.mounts.map(m => m.packFull()),
turrets: this.turrets,
turrets: this.turrets.map(t => t.packFull()),
size: this.size,
delta: this.packDelta()
};

View file

@ -6,6 +6,8 @@ const Laser = require('./shot/laser.js');
class Blaster extends Fixture {
constructor(hardpoint, data) {
super(hardpoint, data);
console.log(data);
}
fire() {

View file

@ -3,8 +3,8 @@
const traits = require('../../traits/turrets.json');
class Fixture {
constructor(hardpoint, data) {
this.hardpoint = hardpoint;
constructor(mount, data) {
this.mount = mount;
this.projectiles = new WeakSet();
@ -12,7 +12,8 @@ class Fixture {
this.rof = turretTraits.rateOfFire;
this.traversal = this.hardpoint.traversal || false;
this.traversal = this.mount.traversal || false;
this.fired = false;
this._angle = this.traversal ? this.traversal.cw : 0;
}
@ -20,6 +21,17 @@ class Fixture {
this.projectiles.forEach(p => p.world.removeBody(p));
}
packFull() {
return {
traversal: this.traversal
}
}
packDelta() {
return [this.traversal];
}
get angle() {
return this._angle;
}

View file

@ -8,6 +8,7 @@ class Mount {
this.type = data.type || 'turret';
this.fixture = false;
this.size = data.size || 0;
this.position = {
x: data.pos[0],
y: data.pos[1]
@ -26,7 +27,8 @@ class Mount {
packFull() {
return {
x: this.position.x,
y: this.position.y
}
}
}