Implemented move function for entities
Does not consider speed (TODO ?)
This commit is contained in:
parent
3666b9e7e9
commit
dafc442512
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
|
||||
{
|
||||
|
|
10
src/Entity.h
10
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;
|
||||
|
|
Loading…
Add table
Reference in a new issue