I am making a simple snake game with SFML and am currently trying to add a sound that plays whenever the snake "eats" one of the dots. So I downloaded a sound file and put it in my project directory and added this to my code:
sf::SoundBuffer buffer;
buffer.loadFromFile("Crunch.wav")
sf::Sound crunch;
crunch.setBuffer(buffer);
if (snake.isTouching(food))
{
crunch.play();
}
When I run the game from Visual Studio it works fine. But I like to put my finished games on my desktop, so I went into my Debug folder, found my .exe file, made a shortcut and placed it on my desktop. But whenever I try to run the program with the desktop shortcut, the message "Failed to open sound file 'Crunch.wav' (couldn't open stream)" shows up on the output window. Does anyone know what is causing this? The program runs as it's supposed to when I run it from VS. Thanks in advance.
argv[0]
inmain()
, or byGetModuleFileName(NULL)