polygon.h 872 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * 2D Physic Engine
  3. * polygon.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_POLYGON_H
  10. #define PHYSICENGINE_SHAPE_POLYGON_H
  11. #include <vector>
  12. #include <physics/vec2.h>
  13. #include <physics/shape.h>
  14. struct polygonShape: public shape
  15. {
  16. std::vector<vec2> vertices;
  17. polygonShape() = default;
  18. polygonShape(const std::vector<vec2> vertices)
  19. {
  20. };
  21. virtual ~polygonShape() = default;
  22. shapeType getType() const override
  23. {
  24. return SHAPE_CIRCLE;
  25. }
  26. double getMomentOfInertial() const override
  27. {
  28. return 0.0;
  29. };
  30. shape *clone() const override
  31. {
  32. return new polygonShape(this->vertices);
  33. };
  34. };
  35. #endif /* PHYSICENGINE_SHAPE_POLYGON_H */