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

1234567891011121314151617181920212223242526
  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 update(const Swan::Context &ctx, float dt) override;
  9. void tick(const Swan::Context &ctx, float dt) override;
  10. void deserialize(const Swan::Context &ctx, const PackObject &obj) override;
  11. PackObject serialize(const Swan::Context &ctx, msgpack::zone &zone) override;
  12. private:
  13. static constexpr float MASS = 80;
  14. static constexpr Swan::Vec2 SIZE = Swan::Vec2(0.5, 0.5);
  15. static constexpr float DESPAWN_TIME = 5 * 60;
  16. static constexpr float BOUNCINESS = 0.6;
  17. ItemStackEntity(): PhysicsEntity(SIZE) {}
  18. float despawnTimer_ = DESPAWN_TIME;
  19. Swan::Item *item_ = NULL;
  20. };