diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-25 20:53:17 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-25 20:53:17 +0200 |
commit | d82f3b7665435abefe84c8dbc16483acd235b478 (patch) | |
tree | 473689f592085a076e45d1cade590ad207cc4840 /src/model/Position.hpp | |
parent | eb40e3de7226d0005ce0a41c67c9355e675a489b (diff) | |
download | rpgedit-d82f3b7665435abefe84c8dbc16483acd235b478.tar rpgedit-d82f3b7665435abefe84c8dbc16483acd235b478.zip |
Move external entity state from Entity to Map
Diffstat (limited to 'src/model/Position.hpp')
-rw-r--r-- | src/model/Position.hpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/model/Position.hpp b/src/model/Position.hpp index b68476f..84044e6 100644 --- a/src/model/Position.hpp +++ b/src/model/Position.hpp @@ -26,6 +26,8 @@ #pragma once +#include "Direction.hpp" + namespace RPGEdit { @@ -33,6 +35,33 @@ namespace Model { struct Position { float x, y; + + Position translate(Direction dir, float amount) const { + Position p = *this; + + switch (dir) { + case NORTH: + p.y -= amount; + break; + + case EAST: + p.x += amount; + break; + + case SOUTH: + p.y += amount; + break; + + case WEST: + p.x -= amount; + } + + return p; + } + + Position operator+(Direction dir) const { + return translate(dir, 1); + } }; } |