Visuel notes
This commit is contained in:
parent
e2fb0d911a
commit
05f8b11dec
14 changed files with 137 additions and 50 deletions
|
@ -1,24 +1,29 @@
|
|||
#include "NoteTile.hpp"
|
||||
#include "NoteSprite.hpp"
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include <SFML/Window/Window.hpp>
|
||||
#include <memory>
|
||||
|
||||
const int NotePlaceXPos[3] = {200, 400, 600};
|
||||
std::vector<std::unique_ptr<NoteTile>> NoteTile::existing_tiles{};
|
||||
// private
|
||||
NoteTile::NoteTile(float play_time, float good_interval, NotePlaceEnum place)
|
||||
NoteTile::NoteTile(float play_time, float good_interval, NotePlaceEnum place,
|
||||
float current_time)
|
||||
: 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;
|
||||
note_sprite.fall_speed = 100;
|
||||
note_sprite.sprite.setPosition(
|
||||
sf::Vector2f(NotePlaceXPos[place],
|
||||
480 - note_sprite.fall_speed * (play_time - current_time)));
|
||||
}
|
||||
|
||||
// public
|
||||
void NoteTile::create(float play_time, float good_interval,
|
||||
NotePlaceEnum place) {
|
||||
void NoteTile::create(float play_time, float good_interval, NotePlaceEnum place,
|
||||
float current_time) {
|
||||
// Can't use make_unique because constructor is private
|
||||
existing_tiles.push_back(
|
||||
std::unique_ptr<NoteTile>(new NoteTile(play_time, good_interval, place)));
|
||||
existing_tiles.push_back(std::unique_ptr<NoteTile>(
|
||||
new NoteTile(play_time, good_interval, place, current_time)));
|
||||
}
|
||||
|
||||
bool NoteTile::checkPress(float press_time, NotePlaceEnum key_pressed) {
|
||||
|
@ -31,3 +36,9 @@ bool NoteTile::checkPress(float press_time, NotePlaceEnum key_pressed) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void NoteTile::update(float dtime, sf::RenderWindow &window) {
|
||||
for (const auto ¬e_tile : NoteTile::existing_tiles) {
|
||||
note_tile->note_sprite.update(dtime, window);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue