From: Andy Belle-Isle Date: Fri, 30 Aug 2019 04:14:07 +0000 (-0400) Subject: Created very basic render component X-Git-Tag: v0.1-alpha~21 X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=70c4239993cbd7fe5604de8f39a3783e9c7a7471;p=clyne%2Fgamedev2.git Created very basic render component --- diff --git a/src/components/Render.hpp b/src/components/Render.hpp new file mode 100644 index 0000000..4444fef --- /dev/null +++ b/src/components/Render.hpp @@ -0,0 +1,52 @@ +/** + * Copyright (C) 2019 Belle-Isle, Andrew + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef RENDER_HPP_ +#define RENDER_HPP_ + +#include + +struct Render : Component, entityx::Component +{ + public: + std::string texture; + bool visible; + + Render(std::string _file): texture(_file), visible(true) {} + Render(): texture(), visible(false) {} + + Render FromLua(sol::object ref) + { + if (ref.get_type() == sol::type::table) { + sol::table tab = ref; + if (tab["visible"].get_type() == sol::type::boolean) { + this->visible = tab["visible"]; + } + if (tab["texture"].get_type() == sol::type::string) { + this->texture = tab["texture"]; + } + } else { + throw std::string( + "Render component table formatted incorrectly" + ); + } + return *this; + } + +}; + +#endif//RENDER_HPP_