new system for synchronizing game objects. fixes #74

This commit is contained in:
logsol 2015-06-22 00:14:17 +02:00
parent 3ef3a6abf9
commit 07dad646cf
19 changed files with 194 additions and 162 deletions

View file

@ -1,9 +1,39 @@
define([
"Game/Core/GameObjects/GameObject"
"Game/Core/GameObjects/GameObject",
"Lib/Vendor/Box2D"
],
function(Parent) {
function (Parent, Box2D) {
return Parent;
"use strict";
function GameObject(physicsEngine, uid) {
Parent.call(this, physicsEngine, uid);
}
GameObject.prototype = Object.create(Parent.prototype);
GameObject.prototype.getUpdateData = function(getSleeping) {
if (!this.body) {
return null;
}
if (this.body.GetType() === Box2D.Dynamics.b2Body.b2_staticBody) {
return null;
}
if (!getSleeping && !this.body.IsAwake()) {
return null;
}
return {
p: this.body.GetPosition(),
a: this.body.GetAngle(),
lv: this.body.GetLinearVelocity(),
av: this.body.GetAngularVelocity()
};
}
return GameObject;
});