reduce update packets sent
This commit is contained in:
parent
d6daed2e9b
commit
ef2d067b38
15 changed files with 67 additions and 14 deletions
|
@ -17,6 +17,7 @@ class Net {
|
|||
});
|
||||
|
||||
this.socket.on('update', data => {
|
||||
window.q = data;
|
||||
game.world.update(data);
|
||||
});
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@ class Asteroid extends Body {
|
|||
}
|
||||
|
||||
updateType(data) {
|
||||
this.debug = data.debug;
|
||||
//this.debug = data.debug;
|
||||
}
|
||||
|
||||
tick() {
|
||||
|
||||
tickType() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ class Body {
|
|||
this.r = values.r;
|
||||
this.rvel = values.rvel;
|
||||
this.updated = 10;
|
||||
this.debug = values.debug;
|
||||
|
||||
this.updateType(values);
|
||||
}
|
||||
|
@ -55,6 +56,10 @@ class Body {
|
|||
}
|
||||
|
||||
tick() {
|
||||
this.tickType();
|
||||
}
|
||||
|
||||
tickType() {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
class Physics {
|
||||
constructor() {
|
||||
Box2D.Common.b2Settings.b2_linearSleepTolerance = 0.01;
|
||||
Box2D.Common.b2Settings.b2_angularSleepTolerance = 0.01;
|
||||
Box2D.Common.b2Settings.b2_timeToSleep = 0;
|
||||
|
||||
this.world = new b2World(new b2Vec2(0, 0));
|
||||
this.toRemove = [];
|
||||
|
@ -31,7 +34,7 @@ class Physics {
|
|||
bodyDef.angularDamping = body.bodyType == 'asteroid' ? 0.003 : 0.06;
|
||||
bodyDef.type = body.bodyType == 'structure' ?
|
||||
b2Body.b2_staticBody : b2Body.b2_dynamicBody;
|
||||
bodyDef.allowSleep = false;
|
||||
if (body.bodyType != 'asteroid') bodyDef.allowSleep = false;
|
||||
var b2body = this.world.CreateBody(bodyDef);
|
||||
|
||||
var fixtureDef = new b2FixtureDef();
|
||||
|
|
|
@ -24,7 +24,7 @@ class Ship extends Body {
|
|||
this.debug = data.debug;
|
||||
}
|
||||
|
||||
tick() {
|
||||
tickType() {
|
||||
if (this.thrust.forward) {
|
||||
var power = this.power.forward;
|
||||
var x = Math.cos(this.getPos().r) * power;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue