It's okay. It's not rude. It's true. I have to master C++ in a better way, but for now I do need some hints. Guys, thank you all for your help. I figured out one of the problems. The reason that the music wouldn't play without the glitchy drawing loop was that it was inside the window loop. Now, I moved the music outside of the drawing loop, but the music won't switch. I've tried a lot of things, but no matter what, the track number won't move on when outside of the window loop. This is what my code looks like now (I simplified it to focus on the basic music problem:
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/Audio.hpp>
int main()
{
//Rendering the Window
sf::RenderWindow window(sf::VideoMode(1200, 400), "Smart Fast Multimedia Library Helmet");
window.setVerticalSyncEnabled(true);
window.setFramerateLimit(30);
//Music Status Text
sf::Text playingText;
sf::Font base;
if (!base.loadFromFile("Base 02.ttf")) {
return -1;
}
playingText.setFont(base);
playingText.setString("Music is Playing");
playingText.setCharacterSize(24);
playingText.setColor(sf::Color::Green);
sf::Text pausedText;
pausedText.setString("Music is Paused");
pausedText.setCharacterSize(24);
pausedText.setColor(sf::Color::Green);
//Vector Container
std::vector <std::string> testingFiles;
testingFiles.push_back("Title Screen.wav");
testingFiles.push_back("firstTrack.wav");
testingFiles.push_back("secondTrack.wav");
testingFiles.push_back("thirdTrack.wav");
//Playlist track number
int trackNumber = 0;
//Opening the music file
sf::Music testingPlaylist;
testingPlaylist.openFromFile(testingFiles.at(trackNumber));
//Playing Music
testingPlaylist.play();
//Making sure that the track moves on
testingPlaylist.getStatus();
if (testingPlaylist.getStatus() == sf::Music::Stopped) {
switch (trackNumber) {
case 0:
trackNumber++;
case 1:
trackNumber++;
break;
case 2:
trackNumber++;
break;
default:
trackNumber = 0;
break;
}
testingPlaylist.play();
}
//Window, sprites, and textures
while (window.isOpen())
{
sf::Texture mainMenuTexture;
mainMenuTexture.loadFromFile("titleScreen.png");
sf::Sprite mainMenuSprite;
mainMenuSprite.setTexture(mainMenuTexture);
//Main Window Loop
sf::Event windowIsClosed;
while (window.pollEvent(windowIsClosed)) //Making sure that the Window can close
{
if (windowIsClosed.type == sf::Event::Closed)
window.close();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && testingPlaylist.getStatus() == sf::Music::Playing) {
testingPlaylist.pause();
}
//Drawing the window
window.clear();
window.draw(mainMenuSprite);
window.display();
} /*Window Loop Ending*/
return 0;
} /*Main Function ending*/