1 2 #ifndef AddPair_H 3 #define AddPair_H 4 5 class AddPair : public Test 6 { 7 public: 8 AddPair()9 AddPair() 10 { 11 m_world->SetGravity(b2Vec2(0.0f,0.0f)); 12 { 13 b2CircleShape shape; 14 shape.m_p.SetZero(); 15 shape.m_radius = 0.1f; 16 17 float minX = -6.0f; 18 float maxX = 0.0f; 19 float minY = 4.0f; 20 float maxY = 6.0f; 21 22 for (int i = 0; i < 400; ++i) 23 { 24 b2BodyDef bd; 25 bd.type = b2_dynamicBody; 26 bd.position = b2Vec2(RandomFloat(minX,maxX),RandomFloat(minY,maxY)); 27 b2Body* body = m_world->CreateBody(&bd); 28 body->CreateFixture(&shape, 0.01f); 29 } 30 } 31 32 { 33 b2PolygonShape shape; 34 shape.SetAsBox(1.5f, 1.5f); 35 b2BodyDef bd; 36 bd.type = b2_dynamicBody; 37 bd.position.Set(-40.0f,5.0f); 38 bd.bullet = true; 39 b2Body* body = m_world->CreateBody(&bd); 40 body->CreateFixture(&shape, 1.0f); 41 body->SetLinearVelocity(b2Vec2(150.0f, 0.0f)); 42 } 43 } 44 Create()45 static Test* Create() 46 { 47 return new AddPair; 48 } 49 }; 50 51 #endif 52