project-kyoku/src/classicgame/classicgraphicsmanager.cpp

27 lines
803 B
C++
Raw Normal View History

2021-06-16 19:11:00 +02:00
#include "classicgraphicsmanager.h"
#include "classicnote.h"
ClassicGraphicsManager::ClassicGraphicsManager(sf::RenderTarget& target) :
_sprite_container({Type::UP, Type::DOWN,
Type::LEFT, Type::RIGHT},
std::make_unique<ClassicSpriteFactory>("VeraMono.ttf")),
_render_target(target)
2021-06-16 19:11:00 +02:00
{}
2021-06-24 00:43:13 +02:00
void ClassicGraphicsManager::initGraphics(ClassicNote* note)
2021-06-16 19:11:00 +02:00
{
note->setSprite(_sprite_container.getSprite(note->type()));
note->sprite()->setCoordinates(note->getCoordinates(), 0, 0);
2021-06-16 19:11:00 +02:00
}
2021-06-24 00:43:13 +02:00
void ClassicGraphicsManager::resetGraphics(ClassicNote* note)
2021-06-16 19:11:00 +02:00
{
_sprite_container.resetSprite(note->sprite(), note->type());
note->setSprite(nullptr);
}
void ClassicGraphicsManager::draw(const ClassicNote *note)
{
_render_target.draw(*note->sprite());
2021-06-16 19:11:00 +02:00
}