You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
project-kyoku/src/classicgame/classicnote.cpp

59 lines
1.4 KiB
C++

#include "classicnote.h"
#include "classicsprite.h"
#include <SFML/Graphics/RenderTarget.hpp>
#include <iostream>
ClassicNote::ClassicNote(const std::vector<microsec>& intervals, microsec perfect_offset,
Action action, const Coordinates& coord) :
Note(perfect_offset),
_coordinates(coord),
_evaluator(intervals, _perfect_offset),
_action(action)
{}
bool ClassicNote::isActive(microsec music_offset) const
{
return _evaluator.isActive(music_offset);
}
void ClassicNote::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
target.draw(*_sprite, states);
}
ClassicNote::GRADE ClassicNote::input(ClassicInputType&& input_data)
{
auto grade = ClassicNote::GRADE::BAD;
if (input_data == _action)
{
grade = _evaluator.calculatePrecision(input_data.timestamp());
}
std::cout << "User input: " << static_cast<int>(grade) << "\n";
return grade;
}
Action ClassicNote::action() const
{
return _action;
}
std::shared_ptr<ClassicSprite> ClassicNote::sprite() const noexcept
{
return _sprite;
}
void ClassicNote::setSprite(const std::shared_ptr<ClassicSprite>& sprite) noexcept
{
_sprite = sprite;
if (_sprite)
_sprite->setCoordinates(_coordinates.x, _coordinates.y);
}
inline const Coordinates& ClassicNote::getCoordinates() const noexcept
{
return _coordinates;
}