Skip to content

Commit

Permalink
add music-playing code
Browse files Browse the repository at this point in the history
  • Loading branch information
ianklatzco committed Aug 19, 2018
1 parent 05cf438 commit d4264c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/main_game_loop/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
6 changes: 5 additions & 1 deletion src/ui_classes/playfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit d4264c2

Please sign in to comment.