35 lines
860 B
C++
35 lines
860 B
C++
|
#include "spritefactorysfml.h"
|
||
|
|
||
|
ClassicSpriteFactorySFML::ClassicSpriteFactorySFML(const std::shared_ptr<sf::RenderTarget>& render_target) :
|
||
|
_render_target(render_target)
|
||
|
{}
|
||
|
|
||
|
std::shared_ptr<ClassicSprite> ClassicSpriteFactorySFML::create(Type type) const
|
||
|
{
|
||
|
sf::RectangleShape sprite;
|
||
|
sprite.setSize({20.f, 20.f});
|
||
|
switch (type)
|
||
|
{
|
||
|
case Type::UP:
|
||
|
sprite.setFillColor(sf::Color(255, 0, 0));
|
||
|
break;
|
||
|
|
||
|
case Type::DOWN:
|
||
|
sprite.setFillColor(sf::Color(0, 255, 0));
|
||
|
break;
|
||
|
|
||
|
case Type::LEFT:
|
||
|
sprite.setFillColor(sf::Color(0, 0, 255));
|
||
|
break;
|
||
|
|
||
|
case Type::RIGHT:
|
||
|
sprite.setFillColor(sf::Color(255, 0, 255));
|
||
|
break;
|
||
|
|
||
|
default: // yellow
|
||
|
sprite.setFillColor(sf::Color(255, 239, 0));
|
||
|
}
|
||
|
|
||
|
return std::make_shared<ClassicSprite>(_render_target, sprite);
|
||
|
}
|