Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

FIX #3 Physic margin

  • Loading branch information...
commit 1fb5f1fd8293109dc97f951bd36ff51bf04f25df 1 parent 6f05ccc
Adrien Crivelli authored
4 application/source/Constants.cpp
View
@@ -12,6 +12,6 @@ namespace Polukili
const float Constants::defaultImpulseSpeed = 10.0f;
const float Constants::timeStep = 1.0f / 60.0f;
const int Constants::iterations = 10;
- const int Constants::maximumPlayers = 4;
-
+ const int Constants::maximumPlayers = 4;
+ const int Constants::physicMargin = 640;
} /* End of namespace Polukili */
5 application/source/Constants.h
View
@@ -48,6 +48,11 @@ namespace Polukili
* The maximum numbers of players in one level. (this should never ever change unless the wii get more wiimotes)
*/
static const int maximumPlayers;
+
+ /**
+ * The margin in pixels applied on the physical world to be sure that no body will be create out of the world.
+ */
+ static const int physicMargin;
};/* End of class Constants*/
} /* End of namespace Polukili*/
4 application/source/Level.cpp
View
@@ -67,10 +67,10 @@ namespace Polukili
// Create the physic world and ground body
b2AABB worldAABB;
- worldAABB.lowerBound.Set(0, 0);
+ worldAABB.lowerBound.Set(-Constants::physicMargin / Constants::pixelsPerUnits, -Constants::physicMargin / Constants::pixelsPerUnits);
float width = (float)atof(mxmlElementGetAttr(data, "width"));
float height = (float)atof(mxmlElementGetAttr(data, "height"));
- worldAABB.upperBound.Set(width / Constants::pixelsPerUnits, height / Constants::pixelsPerUnits);
+ worldAABB.upperBound.Set((Constants::physicMargin + width) / Constants::pixelsPerUnits, (Constants::physicMargin + height) / Constants::pixelsPerUnits);
b2Vec2 gravity(0.0f, Constants::defaultGravity);
bool doSleep = false;
this->world = new b2World(worldAABB, gravity, doSleep);
Please sign in to comment.
Something went wrong with that request. Please try again.