Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class blockClass
- {
- public:
- SDL_Rect rect;
- SDL_Rect midRect;
- b2Vec2 phyPos;
- b2BodyDef bodyDef;
- b2Body *body;
- b2PolygonShape poly;
- float32 angle;
- bool active;
- bool colorSwitch;
- int spawn(b2World *wo, b2Vec2 pos);
- private:
- //int test;
- };
- int blockClass::spawn(b2World *wo, b2Vec2 pos)
- {
- phyPos = pos;
- printf("PhyPos: %.6f, %.6f\n", phyPos.x, phyPos.y);
- bodyDef.type = b2_dynamicBody;
- bodyDef.position.Set(phyPos.x, phyPos.y);
- body = wo->CreateBody(&bodyDef);
- printf("%p\n", body);
- b2Vec2 test = body->GetPosition();
- printf("%f, %f\n", test.x, test.y);
- poly.SetAsBox(0.5f, 0.5f); // 50 x 50
- b2FixtureDef fd;
- fd.shape = &poly;
- fd.density = 1.0f;
- fd.friction = 0.3f;
- printf("Creating\n");
- body->CreateFixture(&fd);
- //body->SetAngularVelocity(1);
- return 0;
- }
Add Comment
Please, Sign In to add comment