Practical Tools for Simple Design
Loading...
Searching...
No Matches
Position.hpp
1#ifndef PTSD_UTIL_POSITION_HPP
2#define PTSD_UTIL_POSITION_HPP
3
4#include <glm/glm.hpp>
5
6namespace Util {
7
8struct PTSDPosition;
9
21public:
22 const int x;
23 const int y;
24 SDLPosition() = delete;
25
26private:
27 friend PTSDPosition;
28 SDLPosition(float x, float y)
29 : x(x),
30 y(y) {}
31};
32
44 float x{};
45 float y{};
46 PTSDPosition() = delete;
47 static PTSDPosition FromSDL(int sdlx, int sdly);
48 PTSDPosition(float x, float y)
49 : x{x},
50 y{y} {};
51 [[deprecated("Implicit conversion will be removed. Use explicit conversion "
52 "instead")]]
53 // `\_(:/)_/`
54 PTSDPosition(glm::vec2 v)
55 : x{v.x},
56 y{v.y} {};
57
58 PTSDPosition operator+(const glm::vec2) const;
59 PTSDPosition operator-(const glm::vec2 vec2) const {
60 return (*this) + (vec2 * (-1.0f));
61 }
62
63 [[deprecated("Implicit conversion will be removed. Use explicit conversion "
64 "instead")]] //
65 operator glm::vec2() const {
66 return {x, y};
67 }
68
69 SDLPosition ToSDLPosition() const;
70};
71
72} // namespace Util
73
74#include "Position.inl"
75
76#endif /* PTSD_UTIL_POSITION_HPP */
Useful tools for development.
Definition: Animation.hpp:12
A class representing a position in a Cartesian coordinates.
Definition: Position.hpp:43
A class representing a position in screen coordinates.
Definition: Position.hpp:20