add basic updating to client on physics
This commit is contained in:
parent
95e0f6b710
commit
1027d980c1
15 changed files with 160 additions and 13 deletions
|
@ -1,10 +1,28 @@
|
|||
'use strict';
|
||||
|
||||
const uuid = require('uuid');
|
||||
|
||||
class Body {
|
||||
constructor() {
|
||||
constructor(world) {
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
this.r = 0;
|
||||
this.b2body = false;
|
||||
this.type = 'dynamic';
|
||||
this.health = 1;
|
||||
this.world = world;
|
||||
this.id = uuid.v4().slice(0, 8);
|
||||
}
|
||||
|
||||
applyDelta() {
|
||||
this.world.applyDelta(this.id, this.pack());
|
||||
}
|
||||
|
||||
pack() {
|
||||
let pos = this.b2body.GetPosition();
|
||||
let rot = this.b2body.GetAngleRadians();
|
||||
|
||||
return [pos.x, pos.y, rot];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue