project-kyoku/modes/classicmode/game/classicspritefactory.h

48 lines
1020 B
C
Raw Normal View History

2021-06-16 13:11:00 -04:00
#pragma once
#include <memory>
#include "classicactions.h"
2021-06-16 13:11:00 -04:00
#include "classicsprite.h"
class ClassicSpriteFactory
{
public:
inline ClassicSpriteFactory(const std::string& font_filename)
{
_font.loadFromFile(font_filename);
}
inline std::shared_ptr<ClassicSprite> create(Type type)
2021-06-16 13:11:00 -04:00
{
sf::RectangleShape sprite;
sprite.setSize({20.f, 20.f});
switch (type)
2021-06-16 13:11:00 -04:00
{
case Type::UP:
2021-06-16 13:11:00 -04:00
sprite.setFillColor(sf::Color(255, 0, 0));
break;
case Type::DOWN:
2021-06-16 13:11:00 -04:00
sprite.setFillColor(sf::Color(0, 255, 0));
break;
case Type::LEFT:
2021-06-16 13:11:00 -04:00
sprite.setFillColor(sf::Color(0, 0, 255));
break;
case Type::RIGHT:
2021-06-16 13:11:00 -04:00
sprite.setFillColor(sf::Color(255, 0, 255));
break;
default: // yellow
sprite.setFillColor(sf::Color(255, 239, 0));
}
return std::make_shared<ClassicSprite>(sprite, _font);
}
private:
sf::Font _font;
};