box.h 891 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * 2D Physic Engine
  3. * box.h:
  4. * Based on pikuma.com Learn Game Physics Engine Programming course.
  5. * Copyright (c) 2022 986-Studio. All rights reserved.
  6. *
  7. * Created by Manoël Trapier on 18/07/2022.
  8. */
  9. #ifndef PHYSICENGINE_SHAPE_BOX_H
  10. #define PHYSICENGINE_SHAPE_BOX_H
  11. #include <vector>
  12. #include <physics/vec2.h>
  13. #include <physics/shapes/polygon.h>
  14. struct boxShape : public polygonShape
  15. {
  16. double width;
  17. double height;
  18. boxShape() = default;
  19. boxShape(double width, double height) : width(width), height(height)
  20. {
  21. };
  22. virtual ~boxShape() = default;
  23. shapeType getType() const override
  24. {
  25. return SHAPE_BOX;
  26. }
  27. double getMomentOfInertial() const override
  28. {
  29. return 0.0;
  30. };
  31. shape *clone() const override
  32. {
  33. return new boxShape(this->width, this->height);
  34. };
  35. };
  36. #endif /* PHYSICENGINE_SHAPE_BOX_H */