A 2D tile-based sandbox game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Body.h 571B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include <SFML/Graphics.hpp>
  3. #include "common.h"
  4. #include "WorldPlane.h"
  5. #include "BoundingBox.h"
  6. namespace Swan {
  7. class Body {
  8. public:
  9. Body(Vec2 size, float mass, Vec2 pos = Vec2::ZERO):
  10. size_(size), mass_(mass), pos_(pos) {};
  11. void friction(Vec2 coef);
  12. void gravity(Vec2 g = Vec2(0, 20));
  13. void collide(WorldPlane &plane);
  14. void outline(Win &win);
  15. void update(float dt);
  16. BoundingBox getBounds() { return { pos_, size_ }; }
  17. Vec2 force_ = { 0, 0 };
  18. Vec2 vel_ = { 0, 0 };
  19. Vec2 size_;
  20. float mass_;
  21. Vec2 pos_;
  22. bool on_ground_ = false;
  23. };
  24. }