From 5f53889d4357d8dba6e726ed38358eca96dbeb47 Mon Sep 17 00:00:00 2001 From: Andy Belle-Isle Date: Mon, 7 Oct 2019 18:35:47 -0400 Subject: Added ability to change rendering offsets and sizes --- src/components/Velocity.hpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/components/Velocity.hpp') diff --git a/src/components/Velocity.hpp b/src/components/Velocity.hpp index 776c1dd..888cbb5 100644 --- a/src/components/Velocity.hpp +++ b/src/components/Velocity.hpp @@ -25,25 +25,24 @@ struct Velocity : Component { public: - double x, y; + float x, y; - Velocity(double _x = 0, double _y = 0) : + Velocity(float _x = 0, float _y = 0) : x(_x), y(_y) {} Velocity FromLua(sol::object ref) { - if (ref.get_type() == sol::type::table) { - sol::table tab = ref; - if (tab["x"] != nullptr) - this->x = tab["x"]; - if (tab["y"] != nullptr) - this->y = tab["y"]; - } else { - throw std::string("Velocity table not formatted properly"); - } + glm::vec2 vel = Script::to(ref); + this->x = vel.x; + this->y = vel.y; return *this; } + glm::vec2 vec() + { + return glm::vec2(x, y); + } + void serialize(cereal::JSONOutputArchive& ar) final { ar(CEREAL_NVP(x), CEREAL_NVP(y)); } -- cgit v1.2.3