Skip to content
Snippets Groups Projects
Commit 96567cd7 authored by Grégoire Payen de La Garanderie's avatar Grégoire Payen de La Garanderie
Browse files

Déplacement du centre du robot et correction d’un bug de collision

parent 096b4e99
No related branches found
No related tags found
No related merge requests found
......@@ -80,25 +80,34 @@ Robot::Robot(b2World & world) : olds(10000)
fixture.density = 10.0f;
fixture.friction = 1.0f;
box.SetAsBox(1.15,1.795, b2Vec2(-1.49,0),0);
box.SetAsBox(1.15,1.795, b2Vec2(-1.49+1.04,0),0);
body->CreateFixture(&fixture);
#ifdef BOX2D_2_0_1
b2Vec2 & v = box.m_vertices;
box.m_vertexCount = 4;
#else
b2Vec2 v[4];
#endif
int inc = 0;
box.m_vertices[inc++].Set(-.97,1.07);
box.m_vertices[inc++].Set(.60,1.07);
box.m_vertices[inc++].Set(0,1.795);
box.m_vertices[inc++].Set(-0.97,1.795);
v[inc++].Set(-.97+1.04,1.07);
v[inc++].Set(.60+1.04,1.07);
v[inc++].Set(0+1.04,1.795);
v[inc++].Set(-0.97+1.04,1.795);
#ifndef BOX2D_2_0_1
box.Set(v, 4);
#endif
body->CreateFixture(&fixture);
inc = 0;
box.m_vertices[inc++].Set(-0.97,-1.795);
box.m_vertices[inc++].Set(0,-1.795);
box.m_vertices[inc++].Set(.60,-1.07);
box.m_vertices[inc++].Set(-.97,-1.07);
v[inc++].Set(-0.97+1.04,-1.795);
v[inc++].Set(0+1.04,-1.795);
v[inc++].Set(.60+1.04,-1.07);
v[inc++].Set(-.97+1.04,-1.07);
#ifndef BOX2D_2_0_1
box.Set(v, 4);
#endif
body->CreateFixture(&fixture);
//setTriangle(box, 0, 0,
#ifdef BOX2D_2_0_1
body->SetMassFromShapes();
......@@ -168,15 +177,15 @@ void Robot::paint(QPainter &p, int dt)
QPoint po[10];
int inc = 0;
po[inc++] = QPoint(0,-179.5);
po[inc++] = QPoint(-262,-179.5);
po[inc++] = QPoint(-262,179.5);
po[inc++] = QPoint(0,179.5);
po[inc++] = QPoint(60,114.5);
po[inc++] = QPoint(60,-114.5);
po[inc++] = QPoint(0+104,-179.5);
po[inc++] = QPoint(-262+104,-179.5);
po[inc++] = QPoint(-262+104,179.5);
po[inc++] = QPoint(0+104,179.5);
po[inc++] = QPoint(60+104,114.5);
po[inc++] = QPoint(60+104,-114.5);
p.drawConvexPolygon(po, 6);
p.drawChord(-103/2, -107, 2*103, 215, 16*90, 16*180);
p.drawChord(-103/2 + 104, -107, 2*103, 215, 16*90, 16*180);
//p.drawRect(-268, -179.5, 268, 359);
//drawTriangle(p, 0, 0, 65, 0, 60, 0);
p.setOpacity(1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment