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 481B

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