mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
first attempt of implmenting asm style box2d engine
This commit is contained in:
parent
ebf167107a
commit
cca3a258ba
12 changed files with 12255 additions and 10876 deletions
|
|
@ -50,7 +50,9 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
|
|||
}
|
||||
|
||||
GameController.prototype.onLevelLoaded = function() {
|
||||
console.log("onLevelLoaded updateWorld pre")
|
||||
this.updateWorld();
|
||||
console.log("onLevelLoaded updateWorld post")
|
||||
};
|
||||
|
||||
GameController.prototype.onUserJoined = function (user) {
|
||||
|
|
@ -115,20 +117,22 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
|
|||
getSleeping = getSleeping || false;
|
||||
|
||||
var update = {};
|
||||
|
||||
var body = this.physicsEngine.world.GetBodyList();
|
||||
|
||||
do {
|
||||
|
||||
if((getSleeping || body.IsAwake()) && body.GetType() === Box2D.Dynamics.b2Body.b2_dynamicBody) {
|
||||
var userData = body.GetUserData();
|
||||
|
||||
|
||||
if (userData instanceof GameObject) {
|
||||
var gameObject = userData;
|
||||
|
||||
update[gameObject.uid] = {
|
||||
p: body.GetPosition(),
|
||||
p: body.GetPosition().Copy(),
|
||||
a: body.GetAngle(),
|
||||
lv: body.GetLinearVelocity(),
|
||||
av: body.GetAngularVelocity()
|
||||
lv: body.GetLinearVelocity().Copy(),
|
||||
av: body.GetAngularVelocity().Copy()
|
||||
};
|
||||
|
||||
if(gameObject instanceof Doll) {
|
||||
|
|
@ -138,6 +142,12 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
|
|||
}
|
||||
}
|
||||
|
||||
if(Settings.USE_ASM) {
|
||||
if(body.GetNext() == body) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} while (body = body.GetNext());
|
||||
|
||||
return update;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue