From 9c49eccab4debab64874e71724988547f2c5114a Mon Sep 17 00:00:00 2001 From: Jeena Paradies Date: Sat, 21 Jul 2012 21:52:40 +0200 Subject: [PATCH 1/4] Added a constant --- app/Game/Core/Collision/Detector.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/Game/Core/Collision/Detector.js b/app/Game/Core/Collision/Detector.js index e69de29..de5bd8d 100644 --- a/app/Game/Core/Collision/Detector.js +++ b/app/Game/Core/Collision/Detector.js @@ -0,0 +1,14 @@ +define(function() { + + function Detector() { + } + + Detecotr.COLLISION_IDENTIFIER_TILE = "tile"; + + Detector.prototype.name = function(arguments){ + return null; + } + + return Detector; + +}); \ No newline at end of file From f3f9138ddcdbf8b2335028dbb6ebeb7906967d66 Mon Sep 17 00:00:00 2001 From: Jeena Paradies Date: Sat, 21 Jul 2012 21:53:11 +0200 Subject: [PATCH 2/4] fixed define-paths and added Detector for the constant --- app/Game/Core/Loader/Level.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Game/Core/Loader/Level.js b/app/Game/Core/Loader/Level.js index a45137d..63f5eff 100644 --- a/app/Game/Core/Loader/Level.js +++ b/app/Game/Core/Loader/Level.js @@ -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, Detector) { // Public function Level(path, engine) { @@ -50,7 +50,7 @@ define(["Chuck/Settings", "Chuck/Constants", "Vendor/Box2D"], function(Settings, fixtureDef.friction = Settings.TILE_FRICTION; fixtureDef.restitution = Settings.TILE_RESTITUTION; fixtureDef.isSensor = false; - fixtureDef.userData = Constants.COLLISION_IDENTIFIER_TILE; + fixtureDef.userData = Detector.COLLISION_IDENTIFIER_TILE; this.engine.createBody(bodyDef).CreateFixture(fixtureDef); } From 7a355e8b9a29696a968d0c6ada18bc2da65614bd Mon Sep 17 00:00:00 2001 From: Jeena Paradies Date: Sat, 21 Jul 2012 22:03:11 +0200 Subject: [PATCH 3/4] fixed define paths, exchanged Constants with Detector stuff --- app/Game/Core/Collision/Detector.js | 11 +++++++---- app/Game/Core/Physics/Doll.js | 12 ++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/Game/Core/Collision/Detector.js b/app/Game/Core/Collision/Detector.js index de5bd8d..b4e7edc 100644 --- a/app/Game/Core/Collision/Detector.js +++ b/app/Game/Core/Collision/Detector.js @@ -3,10 +3,13 @@ define(function() { function Detector() { } - Detecotr.COLLISION_IDENTIFIER_TILE = "tile"; - - Detector.prototype.name = function(arguments){ - return null; + Detector.IDENTIFIER = { + TILE: "tile", + PLAYER: "player", + PLAYER_HEAD: 'head', + PLAYER_CHEST: 'chest', + PLAYER_LEGS: 'legs', + PLAYER_FOOT_SENSOR: 'footsensor' } return Detector; diff --git a/app/Game/Core/Physics/Doll.js b/app/Game/Core/Physics/Doll.js index 26f2277..06a4b97 100644 --- a/app/Game/Core/Physics/Doll.js +++ b/app/Game/Core/Physics/Doll.js @@ -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){ this.id = id; @@ -18,7 +18,7 @@ define(["Vendor/Box2D", "Chuck/Constants", "Chuck/Settings"], function(Box2D, Co bodyDef.fixedRotation = true; bodyDef.linearDamping = Settings.PLAYER_LINEAR_DAMPING; 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); @@ -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)); fixtureDef.shape = headShape; fixtureDef.isSensor = false; - fixtureDef.userData = Constants.COLLISION_IDENTIFIER_PLAYER_HEAD; + fixtureDef.userData = Detector.IDENTIFIER.PLAYER_HEAD; this.body.CreateFixture(fixtureDef); 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)); fixtureDef.shape = bodyShape; fixtureDef.isSensor = false; - fixtureDef.userData = Constants.COLLISION_IDENTIFIER_PLAYER_CHEST; + fixtureDef.userData = Detector.IDENTIFIER.PLAYER_CHEST; this.body.CreateFixture(fixtureDef); 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.friction = Settings.PLAYER_FRICTION; fixtureDef.isSensor = false; - fixtureDef.userData = Constants.COLLISION_IDENTIFIER_PLAYER_LEGS; + fixtureDef.userData = Detector.IDENTIFIER.PLAYER_LEGS; 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)); fixtureDef.shape = feetShape; fixtureDef.isSensor = true; - fixtureDef.userData = Constants.COLLISION_IDENTIFIER_FOOTSENSOR; + fixtureDef.userData = Detector.IDENTIFIER.FOOTSENSOR; this.body.CreateFixture(fixtureDef); this.body.SetActive(false); From fc22ac5643fdd3ff4a9b1d4d808ef942a99c796a Mon Sep 17 00:00:00 2001 From: Jeena Paradies Date: Sat, 21 Jul 2012 22:15:32 +0200 Subject: [PATCH 4/4] changed name and fixed wrong constant name --- app/Game/Core/Loader/Level.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Game/Core/Loader/Level.js b/app/Game/Core/Loader/Level.js index 63f5eff..8e71cd3 100644 --- a/app/Game/Core/Loader/Level.js +++ b/app/Game/Core/Loader/Level.js @@ -1,4 +1,4 @@ -define(["Game/Config/Settings", "Lib/Vendor/Box2D", "Game/Core/Collision/Detector"], function(Settings, Box2D, Detector) { +define(["Game/Config/Settings", "Lib/Vendor/Box2D", "Game/Core/Collision/Detector"], function(Settings, Box2D, CollisionDetector) { // Public function Level(path, engine) { @@ -50,7 +50,7 @@ define(["Game/Config/Settings", "Lib/Vendor/Box2D", "Game/Core/Collision/Detecto fixtureDef.friction = Settings.TILE_FRICTION; fixtureDef.restitution = Settings.TILE_RESTITUTION; fixtureDef.isSensor = false; - fixtureDef.userData = Detector.COLLISION_IDENTIFIER_TILE; + fixtureDef.userData = CollisionDetector.IDENTIFIER.TILE; this.engine.createBody(bodyDef).CreateFixture(fixtureDef); }