aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/components/point.hpp6
-rw-r--r--include/components/solid.hpp5
-rw-r--r--include/components/texture.hpp8
-rw-r--r--include/components/velocity.hpp6
-rw-r--r--include/vec2.hpp12
5 files changed, 29 insertions, 8 deletions
diff --git a/include/components/point.hpp b/include/components/point.hpp
index b0d0f35..0abc081 100644
--- a/include/components/point.hpp
+++ b/include/components/point.hpp
@@ -3,7 +3,11 @@
#include "vec2.hpp"
-struct Point : public Vec2 {};
+struct Point : public Vec2 {
+ constexpr Point() = default;
+ constexpr Point(float x_, float y_): Vec2(x_, y_) {}
+ Point(std::tuple<float, float> tup): Vec2(tup) {}
+};
#endif // COMPONENTS_POINT_HPP
diff --git a/include/components/solid.hpp b/include/components/solid.hpp
index d02d229..87d18e3 100644
--- a/include/components/solid.hpp
+++ b/include/components/solid.hpp
@@ -6,11 +6,12 @@
#include <algorithm>
#include <cstdint>
+#include <string>
class Solid {
public:
- Solid(const char *path) {
- bitmap = sdl2LoadSolid(path);
+ Solid(std::string path) {
+ bitmap = sdl2LoadSolid(path.c_str());
}
~Solid() {
diff --git a/include/components/texture.hpp b/include/components/texture.hpp
index 14253f1..ea08c77 100644
--- a/include/components/texture.hpp
+++ b/include/components/texture.hpp
@@ -4,11 +4,13 @@
#include "components/point.hpp"
#include "window.hpp"
+#include <string>
+
class Texture
{
public:
- Texture(const char *path) {
- tex = sdl2LoadTexture(path);
+ Texture(std::string path) {
+ tex = sdl2LoadTexture(path.c_str());
if (tex)
SDL_QueryTexture(tex, nullptr, nullptr, &w, &h);
}
@@ -27,7 +29,7 @@ public:
}
Point dim() const noexcept {
- return Point {static_cast<float>(w), static_cast<float>(h)};
+ return Point(static_cast<float>(w), static_cast<float>(h));
}
private:
diff --git a/include/components/velocity.hpp b/include/components/velocity.hpp
index 2337ebd..96b8673 100644
--- a/include/components/velocity.hpp
+++ b/include/components/velocity.hpp
@@ -3,7 +3,11 @@
#include "vec2.hpp"
-struct Velocity : public Vec2 {};
+struct Velocity : public Vec2 {
+ constexpr Velocity() = default;
+ constexpr Velocity(float x_, float y_): Vec2(x_, y_) {}
+ Velocity(std::tuple<float, float> tup): Vec2(tup) {}
+};
#endif // COMPONENTS_VELOCITY_HPP
diff --git a/include/vec2.hpp b/include/vec2.hpp
index 6b3c30a..b0f559f 100644
--- a/include/vec2.hpp
+++ b/include/vec2.hpp
@@ -1,8 +1,18 @@
#ifndef VEC2_HPP
#define VEC2_HPP
+#include <tuple>
+
struct Vec2 {
- float x, y;
+ float x = 0.f, y = 0.f;
+
+ constexpr Vec2() = default;
+
+ constexpr Vec2(float x_, float y_):
+ x(x_), y(y_) {}
+
+ Vec2(std::tuple<float, float> tup):
+ x(std::get<0>(tup)), y(std::get<1>(tup)) {}
auto operator+(const Vec2& o) const noexcept {
return Vec2 {x + o.x, y + o.y};