|
|
@@ -27,6 +27,14 @@ collidable::collidable(graphics::object const & obj)
|
|
|
collidable::collidable(Json::Value const & json, graphics::manager const & mgr)
|
|
|
: identity<collidable>(next_id()), render_info_(to_object(json, mgr)) {}
|
|
|
|
|
|
+void collidable::move(math::vec2 const & delta) {
|
|
|
+ render_info_.location.origin += delta;
|
|
|
+ render_info_.points.ll += delta;
|
|
|
+ render_info_.points.lr += delta;
|
|
|
+ render_info_.points.ur += delta;
|
|
|
+ render_info_.points.ul += delta;
|
|
|
+}
|
|
|
+
|
|
|
entity::entity(Json::Value const & json, graphics::manager const & mgr)
|
|
|
: collidable(json, mgr), velocity(to_vec2(json["velocity"])),
|
|
|
frame_texture_coords({make_vector(0.f, 0.f)}),
|
|
|
@@ -37,12 +45,7 @@ entity::entity(Json::Value const & json, graphics::manager const & mgr)
|
|
|
|
|
|
void entity::update(float delta) {
|
|
|
last_position = render_info_.location.origin;
|
|
|
- auto delta_pos = velocity * delta;
|
|
|
- render_info_.location.origin += delta_pos;
|
|
|
- render_info_.points.ll += delta_pos;
|
|
|
- render_info_.points.lr += delta_pos;
|
|
|
- render_info_.points.ur += delta_pos;
|
|
|
- render_info_.points.ul += delta_pos;
|
|
|
+ move(velocity * delta);
|
|
|
velocity += acceleration * delta;
|
|
|
// render_info.angle += angular_velocity * delta;
|
|
|
}
|