Guest User

Untitled

a guest
Jan 21st, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. class blockClass
  2. {
  3. public:
  4. SDL_Rect rect;
  5. SDL_Rect midRect;
  6. b2Vec2 phyPos;
  7. b2BodyDef bodyDef;
  8. b2Body *body;
  9. b2PolygonShape poly;
  10. float32 angle;
  11. bool active;
  12. bool colorSwitch;
  13. int spawn(b2World *wo, b2Vec2 pos);
  14. private:
  15. //int test;
  16. };
  17. int blockClass::spawn(b2World *wo, b2Vec2 pos)
  18. {
  19. phyPos = pos;
  20. printf("PhyPos: %.6f, %.6f\n", phyPos.x, phyPos.y);
  21. bodyDef.type = b2_dynamicBody;
  22. bodyDef.position.Set(phyPos.x, phyPos.y);
  23. body = wo->CreateBody(&bodyDef);
  24. printf("%p\n", body);
  25. b2Vec2 test = body->GetPosition();
  26. printf("%f, %f\n", test.x, test.y);
  27. poly.SetAsBox(0.5f, 0.5f); // 50 x 50
  28. b2FixtureDef fd;
  29. fd.shape = &poly;
  30. fd.density = 1.0f;
  31. fd.friction = 0.3f;
  32. printf("Creating\n");
  33. body->CreateFixture(&fd);
  34. //body->SetAngularVelocity(1);
  35. return 0;
  36. }
Add Comment
Please, Sign In to add comment