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

30 lines
898 B
C++
Raw Normal View History

2021-06-16 19:11:00 +02:00
#include "classicgraphicsmanager.h"
2021-07-15 04:45:52 +02:00
#include "classicsprite.h"
2021-06-16 19:11:00 +02:00
ClassicGraphicsManager::ClassicGraphicsManager(sf::RenderTarget& target) :
_sprite_container({Type::UP, Type::DOWN,
Type::LEFT, Type::RIGHT},
std::make_unique<ClassicSpriteFactory>()),
_render_target(target)
2021-06-16 19:11:00 +02:00
{}
2021-07-15 04:45:52 +02:00
std::shared_ptr<ClassicSprite> ClassicGraphicsManager::getSprite(Type type)
2021-06-16 19:11:00 +02:00
{
2021-07-15 04:45:52 +02:00
return _sprite_container.getSprite(type);
2021-06-16 19:11:00 +02:00
}
2021-07-15 04:45:52 +02:00
void ClassicGraphicsManager::draw(const std::shared_ptr<ClassicSprite>& sprite)
2021-06-16 19:11:00 +02:00
{
2021-07-15 04:45:52 +02:00
_render_target.draw(*sprite);
}
2021-07-15 04:45:52 +02:00
void ClassicGraphicsManager::drawLine(const Coordinates &p1, const Coordinates &p2)
{
2021-07-15 04:45:52 +02:00
sf::VertexArray line(sf::LinesStrip, 2);
line[0].color = sf::Color::Yellow;
line[0].position = {p1.x + 10, p1.y};
line[1].color = sf::Color::Blue;
line[1].position = {p2.x + 10, p2.y};
_render_target.draw(line);
2021-06-16 19:11:00 +02:00
}