Skip to content

Commit

Permalink
fixed client physics engine
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeena Paradies committed Jul 22, 2012
1 parent 8da8ad2 commit 11c642f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/Game/Client/GameController.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define([
"Game/Core/GameController",
"Game/Core/Physics/Engine",
"Game/Client/Physics/Engine",
"Game/Client/View/ViewController",
"Game/Client/Control/KeyboardController",
"Lib/Utilities/RequestAnimFrame"
Expand Down
52 changes: 52 additions & 0 deletions app/Game/Client/Physics/Engine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
define([
"Game/Core/Physics/Engine",
"Game/Config/Settings",
"Game/Client/View/DomController",
"Lib/Vendor/Box2D"
],

function(Parent, Settings, DomController, Box2D) {

function Engine () {
Parent.call(this);

if(Settings.DEBUG_MODE) {
this.setupDebugDraw();
}
}

Engine.prototype.setupDebugDraw = function() {
//var debugSprite = Settings.DEBUG_DRAW_CANVAS_SPRITE;
var debugSprite = Dom.getDebugCanvas().getContext("2d");

// set debug draw
var debugDraw = new Box2D.Dynamics.b2DebugDraw();

debugDraw.SetSprite(debugSprite);
debugDraw.SetDrawScale(Settings.RATIO);
debugDraw.SetFillAlpha(0.5);
debugDraw.SetLineThickness(1.0);

debugDraw.SetFlags(null
| Box2D.Dynamics.b2DebugDraw.e_shapeBit
| Box2D.Dynamics.b2DebugDraw.e_jointBit
//| Box2D.Dynamics.b2DebugDraw.e_coreShapeBit
//| Box2D.Dynamics.b2DebugDraw.e_aabbBit
//| Box2D.Dynamics.b2DebugDraw.e_centerOfMassBit
//| Box2D.Dynamics.b2DebugDraw.e_obbBit
//| Box2D.Dynamics.b2DebugDraw.e_pairBit
);

this.world.SetDebugDraw(debugDraw);
this.world.SetWarmStarting(true);
}


Engine.prototype.update = function() {
Parent.prototype.update.call(this);

this.world.DrawDebugData();
}

return Engine;
})
2 changes: 1 addition & 1 deletion app/Game/Core/Physics/Engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ function(Settings, Box2D, CollisionDetector) {
}

return Engine;
})
});

0 comments on commit 11c642f

Please sign in to comment.