mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
repaired debug draw, added more classes from game draft
This commit is contained in:
parent
1d24d98297
commit
5a6581393e
6 changed files with 354 additions and 71 deletions
|
|
@ -8,6 +8,8 @@ define(["Chuck/Physics/Engine", "Box2D/Box2D"], function(PhysicsEngine, Box2D){
|
|||
this._inputControlUnit;
|
||||
this._keyboardInput;
|
||||
|
||||
this._bodyDef;
|
||||
|
||||
this.init();
|
||||
};
|
||||
|
||||
|
|
@ -15,25 +17,9 @@ define(["Chuck/Physics/Engine", "Box2D/Box2D"], function(PhysicsEngine, Box2D){
|
|||
|
||||
this._physicsEngine = new PhysicsEngine();
|
||||
|
||||
/*
|
||||
var fixDef = new Box2D.Dynamics.b2FixtureDef;
|
||||
fixDef.density = 1.0;
|
||||
fixDef.friction = 0.99;
|
||||
fixDef.restitution = .51;
|
||||
|
||||
var bodyDef = new Box2D.Dynamics.b2BodyDef;
|
||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
fixDef.shape = new Box2D.Collision.Shapes.b2PolygonShape;
|
||||
fixDef.shape.SetAsBox(0.4, 0.4);
|
||||
|
||||
this._physicsEngine.createBody(bodyDef).CreateFixture(fixDef);
|
||||
bodyDef.position.x = 2;
|
||||
bodyDef.position.y = 3;
|
||||
|
||||
console.log('bodying');*/
|
||||
|
||||
|
||||
///------
|
||||
|
||||
|
||||
var world = this._physicsEngine.getWorld();
|
||||
|
||||
|
|
@ -63,25 +49,28 @@ define(["Chuck/Physics/Engine", "Box2D/Box2D"], function(PhysicsEngine, Box2D){
|
|||
bodyDef.position.Set(21.8, 13);
|
||||
world.CreateBody(bodyDef).CreateFixture(fixDef);
|
||||
|
||||
// create some objects
|
||||
// create object
|
||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
|
||||
for(var i = 0; i < 5; i++) {
|
||||
fixDef.shape = new Box2D.Collision.Shapes.b2PolygonShape;
|
||||
fixDef.shape.SetAsBox(0.4, 0.4);
|
||||
fixDef.shape = new Box2D.Collision.Shapes.b2PolygonShape;
|
||||
fixDef.shape.SetAsBox(0.4, 0.4);
|
||||
|
||||
bodyDef.position.x = ((i + 1) * 2) % 8;
|
||||
bodyDef.position.y = 3;
|
||||
bodyDef.position.x = 10;
|
||||
bodyDef.position.y = 2;
|
||||
|
||||
bodyDef.userData = {
|
||||
'bodyId': i + ''
|
||||
};
|
||||
bodyDef.userData = {
|
||||
'bodyId': 1 + ''
|
||||
};
|
||||
|
||||
world.CreateBody(bodyDef).CreateFixture(fixDef);
|
||||
}
|
||||
world.CreateBody(bodyDef).CreateFixture(fixDef);
|
||||
|
||||
|
||||
this._bodyDef = bodyDef;
|
||||
|
||||
|
||||
//this._me = new Chuck.Player(this._physicsEngine, this._repository);
|
||||
|
||||
/*
|
||||
this._me = new Chuck.Player(this._physicsEngine, this._repository);
|
||||
//this._camera = Camera.getInstance()
|
||||
//this._repository = Repository.getInstance();
|
||||
this._physicsEngine.setCollisionDetector(this._me);
|
||||
|
|
@ -108,11 +97,17 @@ define(["Chuck/Physics/Engine", "Box2D/Box2D"], function(PhysicsEngine, Box2D){
|
|||
|
||||
Processor.prototype._update = function(self) {
|
||||
self._physicsEngine.update();
|
||||
|
||||
//console.log(self._physicsEngine.getWorld().GetBodyList().GetPosition());
|
||||
|
||||
//self._repository.update();
|
||||
//self._keyboardInput.update();
|
||||
//self._me.update();
|
||||
//self._camera.update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return Processor;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue