diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-25 23:33:50 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-25 23:33:50 +0200 |
commit | 8b4ca336ce68cc17573115dd07eb1bfc6521b298 (patch) | |
tree | b0a6a457986da0a744c1394cc3788443a50ecaa8 /src/model/Position.hpp | |
parent | d82f3b7665435abefe84c8dbc16483acd235b478 (diff) | |
download | rpgedit-8b4ca336ce68cc17573115dd07eb1bfc6521b298.tar rpgedit-8b4ca336ce68cc17573115dd07eb1bfc6521b298.zip |
Differentiate between int and float positions
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)}; + } }; } |