Merge branch 'restructuring' of github.com:logsol/chuck.js into restructuring

This commit is contained in:
logsol 2012-07-21 23:01:25 +02:00
commit ee5c38cf02
3 changed files with 25 additions and 8 deletions

View file

@ -0,0 +1,17 @@
define(function() {
function Detector() {
}
Detector.IDENTIFIER = {
TILE: "tile",
PLAYER: "player",
PLAYER_HEAD: 'head',
PLAYER_CHEST: 'chest',
PLAYER_LEGS: 'legs',
PLAYER_FOOT_SENSOR: 'footsensor'
}
return Detector;
});

View file

@ -1,4 +1,4 @@
define(["Chuck/Settings", "Chuck/Constants", "Vendor/Box2D"], function(Settings, Constants, Box2D) { define(["Game/Config/Settings", "Lib/Vendor/Box2D", "Game/Core/Collision/Detector"], function(Settings, Box2D, CollisionDetector) {
// Public // Public
function Level(path, engine) { function Level(path, engine) {
@ -50,7 +50,7 @@ define(["Chuck/Settings", "Chuck/Constants", "Vendor/Box2D"], function(Settings,
fixtureDef.friction = Settings.TILE_FRICTION; fixtureDef.friction = Settings.TILE_FRICTION;
fixtureDef.restitution = Settings.TILE_RESTITUTION; fixtureDef.restitution = Settings.TILE_RESTITUTION;
fixtureDef.isSensor = false; fixtureDef.isSensor = false;
fixtureDef.userData = Constants.COLLISION_IDENTIFIER_TILE; fixtureDef.userData = CollisionDetector.IDENTIFIER.TILE;
this.engine.createBody(bodyDef).CreateFixture(fixtureDef); this.engine.createBody(bodyDef).CreateFixture(fixtureDef);
} }

View file

@ -1,4 +1,4 @@
define(["Vendor/Box2D", "Chuck/Constants", "Chuck/Settings"], function(Box2D, Constants, Settings){ define(["Lib/Vendor/Box2D", "Game/Config/Settings", "Game/Core/Collision/Detector"], function(Box2D, Settings, Detector) {
function Doll (physicsEngine, id){ function Doll (physicsEngine, id){
this.id = id; this.id = id;
@ -18,7 +18,7 @@ define(["Vendor/Box2D", "Chuck/Constants", "Chuck/Settings"], function(Box2D, Co
bodyDef.fixedRotation = true; bodyDef.fixedRotation = true;
bodyDef.linearDamping = Settings.PLAYER_LINEAR_DAMPING; bodyDef.linearDamping = Settings.PLAYER_LINEAR_DAMPING;
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody; bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
bodyDef.userData = Constants.COLLISION_IDENTIFIER_PLAYER + '-' + this.id; bodyDef.userData = Detector.IDENTIFIER.PLAYER + '-' + this.id;
this.body = world.CreateBody(bodyDef); this.body = world.CreateBody(bodyDef);
@ -32,14 +32,14 @@ define(["Vendor/Box2D", "Chuck/Constants", "Chuck/Settings"], function(Box2D, Co
headShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, -37 / Settings.RATIO)); headShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, -37 / Settings.RATIO));
fixtureDef.shape = headShape; fixtureDef.shape = headShape;
fixtureDef.isSensor = false; fixtureDef.isSensor = false;
fixtureDef.userData = Constants.COLLISION_IDENTIFIER_PLAYER_HEAD; fixtureDef.userData = Detector.IDENTIFIER.PLAYER_HEAD;
this.body.CreateFixture(fixtureDef); this.body.CreateFixture(fixtureDef);
var bodyShape = new Box2D.Collision.Shapes.b2PolygonShape(); var bodyShape = new Box2D.Collision.Shapes.b2PolygonShape();
bodyShape.SetAsOrientedBox(5 / Settings.RATIO, 16 / Settings.RATIO, new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, -21 / Settings.RATIO)); bodyShape.SetAsOrientedBox(5 / Settings.RATIO, 16 / Settings.RATIO, new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, -21 / Settings.RATIO));
fixtureDef.shape = bodyShape; fixtureDef.shape = bodyShape;
fixtureDef.isSensor = false; fixtureDef.isSensor = false;
fixtureDef.userData = Constants.COLLISION_IDENTIFIER_PLAYER_CHEST; fixtureDef.userData = Detector.IDENTIFIER.PLAYER_CHEST;
this.body.CreateFixture(fixtureDef); this.body.CreateFixture(fixtureDef);
var legsShape = new Box2D.Collision.Shapes.b2CircleShape(); var legsShape = new Box2D.Collision.Shapes.b2CircleShape();
@ -48,7 +48,7 @@ define(["Vendor/Box2D", "Chuck/Constants", "Chuck/Settings"], function(Box2D, Co
fixtureDef.shape = legsShape; fixtureDef.shape = legsShape;
fixtureDef.friction = Settings.PLAYER_FRICTION; fixtureDef.friction = Settings.PLAYER_FRICTION;
fixtureDef.isSensor = false; fixtureDef.isSensor = false;
fixtureDef.userData = Constants.COLLISION_IDENTIFIER_PLAYER_LEGS; fixtureDef.userData = Detector.IDENTIFIER.PLAYER_LEGS;
this.legs = this.body.CreateFixture(fixtureDef); this.legs = this.body.CreateFixture(fixtureDef);
@ -57,7 +57,7 @@ define(["Vendor/Box2D", "Chuck/Constants", "Chuck/Settings"], function(Box2D, Co
feetShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, 0 / Settings.RATIO)); feetShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, 0 / Settings.RATIO));
fixtureDef.shape = feetShape; fixtureDef.shape = feetShape;
fixtureDef.isSensor = true; fixtureDef.isSensor = true;
fixtureDef.userData = Constants.COLLISION_IDENTIFIER_FOOTSENSOR; fixtureDef.userData = Detector.IDENTIFIER.FOOTSENSOR;
this.body.CreateFixture(fixtureDef); this.body.CreateFixture(fixtureDef);
this.body.SetActive(false); this.body.SetActive(false);