SFML community forums

General => General discussions => Topic started by: Andy_ on May 10, 2019, 11:33:52 pm

Title: Playing a random sound in my program
Post by: Andy_ on May 10, 2019, 11:33:52 pm
I'm creating a game in which a random sound should play when reaching a particular score. Sadly, I'm a beginner and I have no idea how to do this, I'm only able to get a random number with of the Randomizer function but it's not helpful in this case anyways. Could anyone help me with this?
Title: Re: Playing a random sound in my program
Post by: Hapax on May 11, 2019, 01:14:37 am
You could have a vector of sf::Sounds and then pick a random number between 0 and the size of vector - 1, which would be the vector's index and therefore which sound that would be used.

Which "Randomizer function"?