Permalink
Browse files

FIX debugdraw didn't draw properly circles

FIX reset constants and bitmasks to original values (before port to GRRLIB)
FIX button '-' to enable/disable debugdraw
  • Loading branch information...
1 parent 4ec3341 commit 9833688eb38122b664029ed8cce932775c14b1fc @PowerKiKi committed Oct 28, 2010
View
4 application/source/Constants.cpp
@@ -5,9 +5,9 @@ namespace Polukili
const string Constants::basePath("/APPS/Polukili/DATA/");
const string Constants::logFilename(Constants::basePath + "polukili.log");
const int Constants::pixelsPerUnits = 48;
- const float Constants::defaultGravity = 1.81f;
+ const float Constants::defaultGravity = 9.81f;
const float Constants::defaultDensity = 5.0f;
- const float Constants::defaultFriction = 0.5f;
+ const float Constants::defaultFriction = 0.5f;
const float Constants::defaultRestitution = 0.2f;
const float Constants::defaultImpulseSpeed = 10.0f;
const float Constants::timeStep = 1.0f / 60.0f;
View
8 application/source/DebugDraw.cpp
@@ -29,7 +29,6 @@ namespace Polukili
v[i].y = Constants::pixelsPerUnits * vertices[i].y;
v[i].z = 0;
colors[i] = RGBA((int)(color.r * 255), (int)(color.g * 255), (int)(color.b * 255), 255);
- Console::log(LOG_INFO, "point[%d] %f, %f, %f, %f", i, v[i].x, v[i].y, vertices[i].x, vertices[i].y);
}
GRRLIB_NGone(v, colors, vertexCount);
@@ -45,7 +44,6 @@ namespace Polukili
v[i].y = Constants::pixelsPerUnits * vertices[i].y;
v[i].z = 0;
colors[i] = RGBA((int)(color.r * 255), (int)(color.g * 255), (int)(color.b * 255), 255);
- Console::log(LOG_INFO, "point[%d] %f, %f", i, v[i].x, v[i].y);
}
GRRLIB_NGoneFilled(v, colors, vertexCount);
@@ -54,19 +52,19 @@ namespace Polukili
void DebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color)
{
u32 c = RGBA((int)(color.r * 255), (int)(color.g * 255), (int)(color.b * 255), 255);
- GRRLIB_Circle(center.y, center.y, radius, c, 0);
+ GRRLIB_Circle(Constants::pixelsPerUnits * center.x, Constants::pixelsPerUnits * center.y, Constants::pixelsPerUnits * radius, c, 0);
}
void DebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color)
{
u32 c = RGBA((int)(color.r * 255), (int)(color.g * 255), (int)(color.b * 255), 255);
- GRRLIB_Circle(center.y, center.y, radius, c, 1);
+ GRRLIB_Circle(Constants::pixelsPerUnits * center.x, Constants::pixelsPerUnits * center.y, Constants::pixelsPerUnits * radius, c, 1);
}
void DebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color)
{
u32 c = RGBA((int)(color.r * 255), (int)(color.g * 255), (int)(color.b * 255), 255);
- GRRLIB_Line(p1.x, p1.y, p2.x, p2.y, c);
+ GRRLIB_Line(Constants::pixelsPerUnits * p1.x, Constants::pixelsPerUnits * p1.y, Constants::pixelsPerUnits * p2.x, Constants::pixelsPerUnits * p2.y, c);
}
void DebugDraw::DrawTransform(const b2Transform& xf)
View
1 application/source/Game.cpp
@@ -36,6 +36,7 @@ namespace Polukili
{
/*************************************************/
Game::Game()
+ : font(0), debugDrawEnabled(false)
{
GRRLIB_Init();
this->font = GRRLIB_LoadTTF(FreeMonoBold_ttf, FreeMonoBold_ttf_size);
View
4 application/source/Level.cpp
@@ -102,7 +102,7 @@ namespace Polukili
b2FixtureDef circleDef;
circleDef.shape = &circleShape;
-// circleDef.filter.categoryBits = ground;
+ circleDef.filter.categoryBits = ground;
this->body->CreateFixture(&circleDef);
@@ -148,7 +148,7 @@ namespace Polukili
b2FixtureDef polygonDef;
polygonDef.shape = &polygonShape;
-// polygonDef.filter.categoryBits = ground;
+ polygonDef.filter.categoryBits = ground;
this->body->CreateFixture(&polygonDef);
Console::log(LOG_INFO, "Level::loadFromXML() - polygon read");
View
4 application/source/Players/Player.cpp
@@ -43,8 +43,8 @@ namespace Polukili
playerDef.density = Constants::defaultDensity;
playerDef.friction = Constants::defaultFriction;
playerDef.restitution = Constants::defaultRestitution;
-// playerDef.filter.categoryBits = players;
-// playerDef.filter.maskBits = ground + enemies;
+ playerDef.filter.categoryBits = players;
+ playerDef.filter.maskBits = ground + enemies;
this->body->CreateFixture(&playerDef);

0 comments on commit 9833688

Please sign in to comment.