Implemented move function for entities
Does not consider speed (TODO ?)
This commit is contained in:
parent
06841915f0
commit
86490f3ff4
2 changed files with 27 additions and 11 deletions
|
@ -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<float>(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
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue