| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- //
- // entity.hpp
- // engine
- //
- // Created by Sam Jaffe on 5/20/19.
- // Copyright © 2019 Sam Jaffe. All rights reserved.
- //
- #pragma once
- #include <json/forwards.h>
- #include "game/engine/engine_fwd.hpp"
- #include "game/graphics/graphics_fwd.h"
- #include "game/graphics/object.hpp"
- #include "game/util/identity.hpp"
- namespace engine {
- class collidable : identity<collidable> {
- public:
- collidable(graphics::object const & obj);
- collidable(Json::Value const & json, graphics::manager const & mgr);
- virtual void collide(collidable const &) {}
- graphics::object const & render_info() const { return render_info_; }
- protected:
- // A mix of position and graphics info
- graphics::object render_info_;
- };
- class entity : public collidable {
- public:
- // TODO: Extract this out?
- entity(Json::Value const & json, graphics::manager const & mgr);
- void update(float delta);
- private:
- // The scene that owns this object
- std::weak_ptr<scene> in_scene;
- // Position info
- math::vec2 last_position{{-1, -1}};
- math::vec2 velocity;
- math::vec2 acceleration{{0, 0}};
- float angular_velocity{0.f};
- // Graphics info
- std::size_t frame_index{0};
- std::vector<math::vec2> frame_texture_coords;
- float scale{1.f};
- collision_t collides_with;
- collision_t collides_as;
- };
- }
|