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.

EntPlayer.h 644B

123456789101112131415161718192021222324252627
  1. #pragma once
  2. #include <swan/swan.h>
  3. class EntPlayer: public Swan::Entity {
  4. public:
  5. class Factory: public Swan::Entity::Factory {
  6. public:
  7. Swan::Entity *create(const Swan::Vec2 &pos) override { return new EntPlayer(pos); }
  8. };
  9. Swan::Body body_;
  10. EntPlayer(Swan::Vec2 pos):
  11. body_(pos, SIZE, MASS) {}
  12. const Swan::Vec2 &getPos() override { return body_.pos_; }
  13. void draw(Swan::Win &win) override;
  14. void update(Swan::WorldPlane &plane, float dt) override;
  15. private:
  16. static constexpr float FORCE = 600;
  17. static constexpr float FRICTION = 100;
  18. static constexpr float MASS = 80;
  19. static constexpr Swan::Vec2 SIZE = Swan::Vec2(1, 2);
  20. };