diff --git a/src/Entity.cpp b/src/Entity.cpp index a6b14a6..a1eb423 100644 --- a/src/Entity.cpp +++ b/src/Entity.cpp @@ -33,16 +33,32 @@ Entity::Entity(const pugi::xml_node& entityNode, sf::Texture* texture) entityNode.attribute("w").as_int(1), entityNode.attribute("h").as_int(1)) {} -void Entity::move() +void Entity::move(Orientation orientation) { - // FIXME : Testing purposes - shape.setRotation(shape.getRotation()+90); + shape.setRotation(static_cast(orientation)); + + sf::Vector2f movementVector(0,0); + switch (orientation) + { + case Orientation::Nort: + movementVector.y = -pro_maat::pixelsPerUnit; + break; + case Orientation::East: + movementVector.x = pro_maat::pixelsPerUnit; + break; + case Orientation::South: + movementVector.y = pro_maat::pixelsPerUnit; + break; + case Orientation::West: + movementVector.x = -pro_maat::pixelsPerUnit; + break; + } + + shape.setPosition(shape.getPosition()+movementVector); } void Entity::update() -{ - -} +{} const sf::RectangleShape& Entity::getShape() const { diff --git a/src/Entity.h b/src/Entity.h index 32ddfb9..0f333cf 100644 --- a/src/Entity.h +++ b/src/Entity.h @@ -29,10 +29,10 @@ enum class State enum class Orientation { - Nort, - East, - South, - West, + Nort = 0, + East = 90, + South = 180, + West = 270, }; @@ -43,7 +43,7 @@ public: Entity(int x, int y, EntityType type, sf::Texture* texture, int width = 1, int height = 1); explicit Entity(const pugi::xml_node& entityNode, sf::Texture* texture); - void move(); + void move(Orientation orientation); void update(); const sf::RectangleShape& getShape() const;