2023-05-08 18:20:55 +02:00
|
|
|
#include "player.hpp"
|
2023-05-10 14:51:09 +02:00
|
|
|
|
2023-05-17 23:22:45 +02:00
|
|
|
#include <utility>
|
|
|
|
|
2023-05-10 14:51:09 +02:00
|
|
|
sf::Vector2f Player::getTrackablePosition() const
|
|
|
|
{
|
|
|
|
return coordinates.isometric().toScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
sf::Vector2f Player::getTrackableSize() const
|
|
|
|
{
|
|
|
|
// TODO: Proper implementation
|
|
|
|
return {static_cast<float>(circle->getRadius() * 2), static_cast<float>(circle->getRadius() * 2)};
|
|
|
|
}
|
|
|
|
|
|
|
|
void Player::update(Game *game)
|
|
|
|
{
|
2023-05-20 00:10:03 +02:00
|
|
|
if (!input->isActive) {
|
|
|
|
isActive = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-05-20 17:08:47 +02:00
|
|
|
auto moveDirection = input->direction.asIsometricVector();
|
2023-05-14 22:23:25 +02:00
|
|
|
auto moveDelta = moveDirection * 30.0f * FRAME_TIME.asSeconds();
|
2023-05-10 14:51:09 +02:00
|
|
|
coordinates.move(moveDelta);
|
|
|
|
circle->coordinates.set(coordinates);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Player::draw(sf::RenderWindow *window) const
|
|
|
|
{
|
|
|
|
circle->draw(window);
|
|
|
|
}
|
|
|
|
|
|
|
|
Player::~Player()
|
|
|
|
{
|
|
|
|
delete circle;
|
|
|
|
}
|
|
|
|
|
2023-05-17 23:22:45 +02:00
|
|
|
Player::Player(std::shared_ptr<InputIdentity> assignedInput, const sf::Color color, WorldCoordinates initCoordinates)
|
2023-05-10 14:51:09 +02:00
|
|
|
{
|
|
|
|
coordinates.set(initCoordinates);
|
|
|
|
|
2023-05-17 23:22:45 +02:00
|
|
|
input = std::move(assignedInput);
|
|
|
|
|
2023-05-14 22:23:25 +02:00
|
|
|
circle = new CircleObject(10, color);
|
2023-05-10 14:51:09 +02:00
|
|
|
circle->coordinates.set(coordinates);
|
|
|
|
}
|