fixed client physics engine

This commit is contained in:
Jeena Paradies 2012-07-22 02:52:43 +02:00
parent 8da8ad2e82
commit 11c642fd7a
3 changed files with 54 additions and 2 deletions

View file

@ -1,6 +1,6 @@
define([ define([
"Game/Core/GameController", "Game/Core/GameController",
"Game/Core/Physics/Engine", "Game/Client/Physics/Engine",
"Game/Client/View/ViewController", "Game/Client/View/ViewController",
"Game/Client/Control/KeyboardController", "Game/Client/Control/KeyboardController",
"Lib/Utilities/RequestAnimFrame" "Lib/Utilities/RequestAnimFrame"

View file

@ -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;
})

View file

@ -33,4 +33,4 @@ function(Settings, Box2D, CollisionDetector) {
} }
return Engine; return Engine;
}) });