diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-23 00:13:05 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-23 00:13:05 +0200 |
commit | 11e77a9d65972c8e59aefd72419dfcf9036e9f6a (patch) | |
tree | 03288809e9a592849e881d6f3baae2eb41bee5cb /src/model/Entity.hpp | |
parent | c9b41bc1022c75ac6da84f4fa503dd8231a96cf2 (diff) | |
download | rpgedit-11e77a9d65972c8e59aefd72419dfcf9036e9f6a.tar rpgedit-11e77a9d65972c8e59aefd72419dfcf9036e9f6a.zip |
Allow player movement
Diffstat (limited to 'src/model/Entity.hpp')
-rw-r--r-- | src/model/Entity.hpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/model/Entity.hpp b/src/model/Entity.hpp index 518ce5f..a61ae21 100644 --- a/src/model/Entity.hpp +++ b/src/model/Entity.hpp @@ -63,10 +63,31 @@ public: return dir; } - void move(float newX, float newY) { + void moveTo(float newX, float newY) { x = newX; y = newY; } + + void move(Direction direction, float amount = 1) { + dir = direction; + + switch (direction) { + case NORTH: + y -= amount; + break; + + case EAST: + x += amount; + break; + + case SOUTH: + y += amount; + break; + + case WEST: + x -= amount; + } + } }; } |