diff --git a/SDLU/CMakeLists.txt b/SDLU/CMakeLists.txt index 9013469..7756ad3 100644 --- a/SDLU/CMakeLists.txt +++ b/SDLU/CMakeLists.txt @@ -10,4 +10,6 @@ target_include_directories(${PNAME} PRIVATE target_link_libraries(${PNAME} PRIVATE ${CMAKE_BINARY_DIR}/3rdparty/SDL/SDL2d.lib -) \ No newline at end of file +) + +add_subdirectory(structures) \ No newline at end of file diff --git a/SDLU/SDLU.hpp b/SDLU/SDLU.hpp index 443042f..df523b9 100644 --- a/SDLU/SDLU.hpp +++ b/SDLU/SDLU.hpp @@ -1,3 +1,3 @@ #pragma once -#include "SDL.h" \ No newline at end of file +#include "structures/Vector2.hpp" \ No newline at end of file diff --git a/SDLU/structures/CMakeLists.txt b/SDLU/structures/CMakeLists.txt new file mode 100644 index 0000000..b1be5b7 --- /dev/null +++ b/SDLU/structures/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${PNAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/Vector2.hpp +) \ No newline at end of file diff --git a/SDLU/structures/Vector2.hpp b/SDLU/structures/Vector2.hpp new file mode 100644 index 0000000..2bd8664 --- /dev/null +++ b/SDLU/structures/Vector2.hpp @@ -0,0 +1,46 @@ +/** + * @file Vector2.hpp + * @brief Provides a structure for simple vector calculations + * @author Lauchmelder23 + * @date 16.05.2020 + */ + +#include + +namespace sdlu +{ + template< + typename T, + typename = typename std::enable_if::value, T>::type + > struct Vector2 + { + T x; ///< x component + T y; ///< y component + + /// Initializes a zero vector + Vector2() : + x(0), y(0) + { + // Empty + } + + /// Initializes a vector with default values + Vector2(T x, T y) : + x(x), y(y) + { + // Empty + } + + /// Copies the components of a vector + Vector2(const Vector2& other) : + x(other.x), y(other.y) + { + // Empty + } + }; + + typedef Vector2 Vector2u, Vec2u; + typedef Vector2 Vector2i, Vec2i; + typedef Vector2 Vector2f, Vec2f; + typedef Vector2 Vector2d, Vec2d; +} \ No newline at end of file diff --git a/SDLU_Example/main.cpp b/SDLU_Example/main.cpp index 65df789..dcb4d5f 100644 --- a/SDLU_Example/main.cpp +++ b/SDLU_Example/main.cpp @@ -1,6 +1,11 @@ #include "header.hpp" +#include + int main(int argc, char** argv) { + sdlu::Vector2f vec(.4f, -2.3f); + std::cout << "Vector2f: " << vec.x << ", " << vec.y << std::endl; + return 0; } \ No newline at end of file