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

30 lines
898 B
C++
Raw Normal View History

2021-06-16 13:11:00 -04:00
#include "classicgraphicsmanager.h"
2021-07-14 22:45:52 -04:00
#include "classicsprite.h"
2021-06-16 13:11:00 -04: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 13:11:00 -04:00
{}
2021-07-14 22:45:52 -04:00
std::shared_ptr<ClassicSprite> ClassicGraphicsManager::getSprite(Type type)
2021-06-16 13:11:00 -04:00
{
2021-07-14 22:45:52 -04:00
return _sprite_container.getSprite(type);
2021-06-16 13:11:00 -04:00
}
2021-07-14 22:45:52 -04:00
void ClassicGraphicsManager::draw(const std::shared_ptr<ClassicSprite>& sprite)
2021-06-16 13:11:00 -04:00
{
2021-07-14 22:45:52 -04:00
_render_target.draw(*sprite);
}
2021-07-14 22:45:52 -04:00
void ClassicGraphicsManager::drawLine(const Coordinates &p1, const Coordinates &p2)
{
2021-07-14 22:45:52 -04: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 13:11:00 -04:00
}