From d4264c20d604e863464acff916f413c2aec8c9a0 Mon Sep 17 00:00:00 2001 From: Ian Klatzco Date: Sat, 18 Aug 2018 20:45:39 -0700 Subject: [PATCH] add music-playing code --- src/main_game_loop/main.cpp | 11 +++++++++++ src/ui_classes/playfield.cpp | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main_game_loop/main.cpp b/src/main_game_loop/main.cpp index ef12d63..09cf5e7 100644 --- a/src/main_game_loop/main.cpp +++ b/src/main_game_loop/main.cpp @@ -50,6 +50,17 @@ int main() notedata simfile_inst("songs/Checkpoint/Checkpoint.sm"); playfield_inst.active_simfile = simfile_inst; + // = Playing Music ==================================================== + + // Load a sound buffer from a wav file + sf::SoundBuffer buffer; + if (!buffer.loadFromFile("songs/Checkpoint/Checkpoint.ogg")) + abort(); + + // Create a sound instance and play it + sf::Sound sound(buffer); + sound.play(); + // = Main Loop ======================================================== while (window.isOpen()) diff --git a/src/ui_classes/playfield.cpp b/src/ui_classes/playfield.cpp index 1c2ec9a..5f4a724 100644 --- a/src/ui_classes/playfield.cpp +++ b/src/ui_classes/playfield.cpp @@ -226,5 +226,9 @@ void playfield::draw_measure(measure & m, int index_in_measure_vector) float playfield::calculate_note_y_pos(note & note_inst, int index_in_measure_vector, int index) { int speedmod = SPEEDMOD; - return WINDOW_HEIGHT + (index_in_measure_vector * speedmod * 4) + (speedmod * index) - ( song_clock.getElapsedTime().asSeconds() * speedmod); + float bpm = 140; + return WINDOW_HEIGHT + + (index_in_measure_vector * speedmod * 4 / 1.4) // move b/c measure in song + + (speedmod * index / 1.4) // move b/c note in measure + - ( (song_clock.getElapsedTime().asSeconds() ) * speedmod); // move b/c time elapsed }