mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
Added Player
This commit is contained in:
parent
2ce46e1f43
commit
7560fd634a
3 changed files with 93 additions and 98 deletions
|
|
@ -1,4 +1,4 @@
|
|||
define(["Chuck/Physics/Engine", "Box2D/Box2D"], function(PhysicsEngine, Box2D){
|
||||
define(["Chuck/Physics/Engine", "Chuck/Player", "Box2D/Box2D"], function(PhysicsEngine, Player, Box2D){
|
||||
|
||||
function Processor () {
|
||||
this._me;
|
||||
|
|
@ -20,56 +20,48 @@ define(["Chuck/Physics/Engine", "Box2D/Box2D"], function(PhysicsEngine, Box2D){
|
|||
|
||||
|
||||
|
||||
{
|
||||
var world = this._physicsEngine.getWorld();
|
||||
|
||||
var world = this._physicsEngine.getWorld();
|
||||
var fixDef = new Box2D.Dynamics.b2FixtureDef;
|
||||
fixDef.density = 1.0;
|
||||
fixDef.friction = 0.99;
|
||||
fixDef.restitution = .51;
|
||||
var bodyDef = new Box2D.Dynamics.b2BodyDef;
|
||||
|
||||
// create ground
|
||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_staticBody;
|
||||
fixDef.shape = new Box2D.Collision.Shapes.b2PolygonShape;
|
||||
fixDef.shape.SetAsBox(20, 2);
|
||||
bodyDef.position.Set(10, 400 / 30 + 1.8);
|
||||
world.CreateBody(bodyDef).CreateFixture(fixDef);
|
||||
bodyDef.position.Set(10, -1.8);
|
||||
world.CreateBody(bodyDef).CreateFixture(fixDef);
|
||||
fixDef.shape.SetAsBox(2, 14);
|
||||
bodyDef.position.Set(-1.8, 13);
|
||||
world.CreateBody(bodyDef).CreateFixture(fixDef);
|
||||
bodyDef.position.Set(21.8, 13);
|
||||
world.CreateBody(bodyDef).CreateFixture(fixDef);
|
||||
|
||||
var fixDef = new Box2D.Dynamics.b2FixtureDef;
|
||||
fixDef.density = 1.0;
|
||||
fixDef.friction = 0.99;
|
||||
fixDef.restitution = .51;
|
||||
|
||||
var bodyDef = new Box2D.Dynamics.b2BodyDef;
|
||||
|
||||
// create ground
|
||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_staticBody;
|
||||
fixDef.shape = new Box2D.Collision.Shapes.b2PolygonShape;
|
||||
fixDef.shape.SetAsBox(20, 2);
|
||||
// create object
|
||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
fixDef.shape = new Box2D.Collision.Shapes.b2PolygonShape;
|
||||
fixDef.shape.SetAsBox(0.4, 0.4);
|
||||
bodyDef.position.x = 10;
|
||||
bodyDef.position.y = 2;
|
||||
bodyDef.userData = {
|
||||
'bodyId': 1 + ''
|
||||
};
|
||||
|
||||
bodyDef.position.Set(10, 400 / 30 + 1.8);
|
||||
world.CreateBody(bodyDef).CreateFixture(fixDef);
|
||||
this._bodyDef = bodyDef;
|
||||
}
|
||||
|
||||
world.CreateBody(bodyDef).CreateFixture(fixDef);
|
||||
bodyDef.position.Set(10, -1.8);
|
||||
|
||||
world.CreateBody(bodyDef).CreateFixture(fixDef);
|
||||
fixDef.shape.SetAsBox(2, 14);
|
||||
|
||||
bodyDef.position.Set(-1.8, 13);
|
||||
world.CreateBody(bodyDef).CreateFixture(fixDef);
|
||||
|
||||
bodyDef.position.Set(21.8, 13);
|
||||
world.CreateBody(bodyDef).CreateFixture(fixDef);
|
||||
|
||||
// create object
|
||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
|
||||
fixDef.shape = new Box2D.Collision.Shapes.b2PolygonShape;
|
||||
fixDef.shape.SetAsBox(0.4, 0.4);
|
||||
|
||||
bodyDef.position.x = 10;
|
||||
bodyDef.position.y = 2;
|
||||
|
||||
bodyDef.userData = {
|
||||
'bodyId': 1 + ''
|
||||
};
|
||||
|
||||
world.CreateBody(bodyDef).CreateFixture(fixDef);
|
||||
|
||||
|
||||
this._bodyDef = bodyDef;
|
||||
|
||||
|
||||
//this._me = new Chuck.Player(this._physicsEngine, this._repository);
|
||||
|
||||
this._me = new Player(this._physicsEngine, null);
|
||||
this._me.spawn(100, 0);
|
||||
|
||||
/*
|
||||
//this._camera = Camera.getInstance()
|
||||
//this._repository = Repository.getInstance();
|
||||
|
|
@ -80,7 +72,7 @@ define(["Chuck/Physics/Engine", "Box2D/Box2D"], function(PhysicsEngine, Box2D){
|
|||
new Chuck.Loader.Level(this._physicsEngine);
|
||||
//new Items();
|
||||
|
||||
this._me.spawn(100, 0);
|
||||
|
||||
//this._camera.follow(this._me);
|
||||
*/
|
||||
setInterval(this._update, 1000/60, this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue