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

1234567891011121314151617181920212223242526272829
  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. Vec2 force_ = { 0, 0 };
  9. Vec2 vel_ = { 0, 0 };
  10. Vec2 pos_;
  11. Vec2 size_;
  12. float mass_;
  13. Body(Vec2 pos, Vec2 size, float mass):
  14. pos_(pos), size_(size), mass_(mass) {};
  15. void friction(float coef);
  16. void gravity(Vec2 g = Vec2(0, 9.81));
  17. void collide(WorldPlane &plane);
  18. void outline(Win &win);
  19. void update(float dt);
  20. };
  21. }