mirror of
https://github.com/ApfelTeeSaft/gameBase.git
synced 2026-08-26 19:23:30 +00:00
implemented paylist shuffling
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
#include <SFML/Audio.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <random>
|
||||
|
||||
namespace gameBase{
|
||||
using namespace std;
|
||||
|
||||
@@ -75,6 +78,12 @@ namespace gameBase{
|
||||
for(string path : playlist)
|
||||
currentPlaylistTracks.push_back(Track(path));
|
||||
|
||||
if(shuffle){
|
||||
random_device rd;
|
||||
mt19937 g(rd());
|
||||
std::shuffle(currentPlaylistTracks.begin(), currentPlaylistTracks.end(), g);
|
||||
}
|
||||
|
||||
originalPlaylist = playlist;
|
||||
currentTrackId = 0;
|
||||
currentPlaylistTracks[currentTrackId].soundObj->play();
|
||||
|
||||
Reference in New Issue
Block a user