00001 00002 // 00003 // Thor C++ Library 00004 // Copyright (c) 2011-2012 Jan Haller 00005 // 00006 // This software is provided 'as-is', without any express or implied 00007 // warranty. In no event will the authors be held liable for any damages 00008 // arising from the use of this software. 00009 // 00010 // Permission is granted to anyone to use this software for any purpose, 00011 // including commercial applications, and to alter it and redistribute it 00012 // freely, subject to the following restrictions: 00013 // 00014 // 1. The origin of this software must not be misrepresented; you must not 00015 // claim that you wrote the original software. If you use this software 00016 // in a product, an acknowledgment in the product documentation would be 00017 // appreciated but is not required. 00018 // 00019 // 2. Altered source versions must be plainly marked as such, and must not be 00020 // misrepresented as being the original software. 00021 // 00022 // 3. This notice may not be removed or altered from any source distribution. 00023 // 00025 00028 00029 #ifndef THOR_OBJECT2D_HPP 00030 #define THOR_OBJECT2D_HPP 00031 00032 #include <Thor/Config.hpp> 00033 00034 #include <SFML/System/Vector2.hpp> 00035 00036 00037 namespace thor 00038 { 00039 00042 00045 class THOR_API Positionable 00046 { 00047 // --------------------------------------------------------------------------------------------------------------------------- 00048 // Public member functions 00049 public: 00052 explicit Positionable(sf::Vector2f position = sf::Vector2f(0.f, 0.f)); 00053 00056 void SetPosition(sf::Vector2f position); 00057 00060 void SetPosition(float x, float y); 00061 00064 void Move(sf::Vector2f offset); 00065 00068 void Move(float offsetX, float offsetY); 00069 00072 sf::Vector2f GetPosition() const; 00073 00074 00075 // --------------------------------------------------------------------------------------------------------------------------- 00076 // Private variables 00077 private: 00078 sf::Vector2f mPosition; 00079 }; 00080 00081 00084 class THOR_API Rotatable 00085 { 00086 // --------------------------------------------------------------------------------------------------------------------------- 00087 // Public member functions 00088 public: 00091 explicit Rotatable(float rotation = 0.f); 00092 00095 void SetRotation(float rotation); 00096 00099 void Rotate(float angle); 00100 00103 float GetRotation() const; 00104 00105 00106 // --------------------------------------------------------------------------------------------------------------------------- 00107 // Private variables 00108 private: 00109 float mRotation; 00110 }; 00111 00112 00115 class THOR_API Scalable 00116 { 00117 // --------------------------------------------------------------------------------------------------------------------------- 00118 // Public member functions 00119 public: 00122 explicit Scalable(sf::Vector2f scale = sf::Vector2f(1.f, 1.f)); 00123 00126 void SetScale(sf::Vector2f scale); 00127 00130 void SetScale(float scaleX, float scaleY); 00131 00134 void Scale(sf::Vector2f factor); 00135 00138 void Scale(float factorX, float factorY); 00139 00142 sf::Vector2f GetScale() const; 00143 00144 00145 // --------------------------------------------------------------------------------------------------------------------------- 00146 // Private variables 00147 private: 00148 sf::Vector2f mScale; 00149 }; 00150 00152 00153 } // namespace thor 00154 00155 #endif // THOR_OBJECT2D_HPP