entity.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // entity.hpp
  3. // engine
  4. //
  5. // Created by Sam Jaffe on 5/20/19.
  6. // Copyright © 2019 Sam Jaffe. All rights reserved.
  7. //
  8. #pragma once
  9. #include <json/forwards.h>
  10. #include "game/engine/engine_fwd.hpp"
  11. #include "game/graphics/graphics_fwd.h"
  12. #include "game/graphics/object.hpp"
  13. #include "game/util/identity.hpp"
  14. namespace engine {
  15. class entity : identity<entity> {
  16. public:
  17. // TODO: Extract this out?
  18. entity(Json::Value const & json, graphics::manager const & mgr);
  19. void update(float delta);
  20. void collide(entity const &);
  21. graphics::object const & render_info() const { return render_info_; }
  22. private:
  23. // The scene that owns this object
  24. std::weak_ptr<scene> in_scene;
  25. // Position info
  26. math::vec2 last_position;
  27. math::vec2 velocity;
  28. math::vec2 acceleration;
  29. float angular_velocity;
  30. // A mix of position and graphics info
  31. graphics::object render_info_;
  32. // Graphics info
  33. std::size_t frame_index;
  34. std::vector<math::vec2> frame_texture_coords;
  35. float scale;
  36. collision_t collides_with;
  37. collision_t collides_as;
  38. };
  39. }