-
-
Save plonp/f18468e7dd9228380f2ec047a5666c0b to your computer and use it in GitHub Desktop.
array_shuffle() for GameMaker Studio 2.3.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adds to GMS2.3.1's new "array_" functions. | |
// Based of Fisher-Yates Shuffle https://bost.ocks.org/mike/shuffle/ | |
function array_shuffle(_array) { | |
var _len = array_length(_array), _last = 0, _i = 0; | |
while(_len) { | |
_i = irandom(--_len); | |
_last = _array[_len]; | |
_array[_len] = _array[_i]; | |
_array[_i] = _last; | |
} | |
return _array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment