circle.h 1003 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * 2D Physic Engine
  3. * circle.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_CIRCLE_H
  10. #define PHYSICENGINE_SHAPE_CIRCLE_H
  11. #include <physics/body.h>
  12. #include <physics/shape.h>
  13. #include <graphics.h>
  14. struct circleShape: public shape
  15. {
  16. double radius;
  17. circleShape() = default;
  18. circleShape(const double radius) : radius(radius) {};
  19. virtual ~circleShape() = default;
  20. shapeType getType() const override
  21. {
  22. return SHAPE_CIRCLE;
  23. }
  24. double getMomentOfInertial() const override
  25. {
  26. return 0.0;
  27. };
  28. shape *clone() const override
  29. {
  30. return new circleShape(this->radius);
  31. };
  32. void draw(const body &bod) override
  33. {
  34. graphics::draw::circle(bod.position.x, bod.position.y, this->radius, bod.rotation, bod.colour);
  35. };
  36. };
  37. #endif /* PHYSICENGINE_SHAPE_CIRCLE_H */