project-kyoku/modes/classicmode/game/classicsprite.cpp

64 lines
1.3 KiB
C++
Raw Normal View History

#include "classicsprite.h"
#include <SFML/Graphics/RenderTarget.hpp>
ClassicSprite::ClassicSprite(const sf::RectangleShape& shape) :
2021-06-16 13:11:00 -04:00
_prototype(shape),
2021-06-11 12:58:44 -04:00
_shape(shape),
_trail(shape)
{}
void ClassicSprite::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
target.draw(_shape, states);
2021-06-11 12:58:44 -04:00
target.draw(_trail, states);
}
void ClassicSprite::reset()
{
_shape.setPosition(0, 0);
_trail.setPosition(0, 0);
2021-06-16 13:11:00 -04:00
_shape = _prototype;
_trail = _prototype;
}
void ClassicSprite::setCoordinates(const Coordinates& coordinates)
{
_shape.setPosition(coordinates.x, coordinates.y);
}
void ClassicSprite::setTrailCoordinates(const Coordinates &coordinates)
{
_trail.setPosition(coordinates.x, coordinates.y);
2021-06-11 12:58:44 -04:00
}
Coordinates ClassicSprite::coordinates() const
2021-06-23 18:43:13 -04:00
{
return {_shape.getPosition().x, _shape.getPosition().y};
2021-06-23 18:43:13 -04:00
}
2021-07-14 22:45:52 -04:00
Coordinates ClassicSprite::trailCoordinates() const
{
return {_trail.getPosition().x, _trail.getPosition().y};
}
void ClassicSprite::setColor(const sf::Color& color)
{
_shape.setFillColor(color);
}
void ClassicSprite::setTrailColor(const sf::Color& color)
{
_trail.setFillColor(color);
}
sf::Color ClassicSprite::color() const
{
return _shape.getFillColor();
}
sf::Color ClassicSprite::trailColor() const
{
return _trail.getFillColor();
}