diff options
Diffstat (limited to 'src/model/Position.hpp')
-rw-r--r-- | src/model/Position.hpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/model/Position.hpp b/src/model/Position.hpp index 84044e6..a88c151 100644 --- a/src/model/Position.hpp +++ b/src/model/Position.hpp @@ -33,10 +33,11 @@ namespace RPGEdit { namespace Model { +template<typename T> struct Position { - float x, y; + T x, y; - Position translate(Direction dir, float amount) const { + Position translate(Direction dir, T amount) const { Position p = *this; switch (dir) { @@ -59,9 +60,14 @@ struct Position { return p; } - Position operator+(Direction dir) const { + Position<T> operator+(Direction dir) const { return translate(dir, 1); } + + template<typename T2> + explicit operator Position<T2>() const { + return Position<T2>{T2(x), T2(y)}; + } }; } |