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

64 lines
1.3 KiB
C++

#include "classicsprite.h"
#include <SFML/Graphics/RenderTarget.hpp>
ClassicSprite::ClassicSprite(const sf::RectangleShape& shape) :
_prototype(shape),
_shape(shape),
_trail(shape)
{}
void ClassicSprite::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
target.draw(_shape, states);
target.draw(_trail, states);
}
void ClassicSprite::reset()
{
_shape.setPosition(0, 0);
_trail.setPosition(0, 0);
_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);
}
Coordinates ClassicSprite::coordinates() const
{
return {_shape.getPosition().x, _shape.getPosition().y};
}
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();
}