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.

ItemStackEntity.h 746B

12345678910111213141516171819202122
  1. #pragma once
  2. #include <swan/swan.h>
  3. class ItemStackEntity: public Swan::PhysicsEntity {
  4. public:
  5. ItemStackEntity(const Swan::Context &ctx, Swan::Vec2 pos, const std::string &item);
  6. ItemStackEntity(const Swan::Context &ctx, const PackObject &obj);
  7. void draw(const Swan::Context &ctx, Swan::Win &win) override;
  8. void tick(const Swan::Context &ctx, float dt) override;
  9. void deserialize(const Swan::Context &ctx, const PackObject &obj) override;
  10. PackObject serialize(const Swan::Context &ctx, msgpack::zone &zone) override;
  11. private:
  12. static constexpr float MASS = 80;
  13. static constexpr Swan::Vec2 SIZE = Swan::Vec2(0.5, 0.5);
  14. static constexpr float DESPAWN_TIME = 5 * 60;
  15. float despawn_timer_ = DESPAWN_TIME;
  16. Swan::Item *item_ = NULL;
  17. };