31 lines
1 KiB
C++
31 lines
1 KiB
C++
#include "NoteTile.hpp"
|
|
#include "NoteSprite.hpp"
|
|
#include <SFML/System/Vector2.hpp>
|
|
|
|
std::vector<std::unique_ptr<NoteTile>> NoteTile::existing_tiles;
|
|
|
|
// private
|
|
NoteTile::NoteTile(float play_time, float good_interval, NotePlaceEnum place)
|
|
: play_time(play_time), good_interval(good_interval), place(place),
|
|
note_sprite() {
|
|
// TODO do real note_sprite init, make it fall at good speed far enough...
|
|
note_sprite.sprite.setPosition(sf::Vector2f(200, 0));
|
|
note_sprite.fall_speed = 1;
|
|
NoteTile::existing_tiles.push_back(std::unique_ptr<NoteTile>(this));
|
|
}
|
|
|
|
// public
|
|
void NoteTile::create(float play_time, float good_interval,
|
|
NotePlaceEnum place) {
|
|
NoteTile(play_time, good_interval, place);
|
|
}
|
|
|
|
bool NoteTile::CheckPress(float press_time, NotePlaceEnum) {
|
|
for (const auto ¬e_tile : NoteTile::existing_tiles) {
|
|
if (note_tile->play_time - note_tile->good_interval / 2 < press_time &&
|
|
note_tile->play_time + note_tile->good_interval / 2 > press_time) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|