From 11e77a9d65972c8e59aefd72419dfcf9036e9f6a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 23 Sep 2014 00:13:05 +0200 Subject: Allow player movement --- src/model/Entity.hpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/model/Entity.hpp') 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; + } + } }; } -- cgit v1.2.3