Shuffle list by Tebbsy3rd Feb 2007 6:40
|
---|
Summary Create a list of numbers between 1 and 52 ensuring that no value is entered twice. Useful if you are wanting to "shuffle" a deck of cards in a game. The list is created i Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com REM Declare this array at the top of the program Dim cards(52) REM -------------------------------------------- function shuffle() i=1 RANDOMIZE rnd(256) while i<53 looper: k=0 z=rnd(51)+1 for j = 1 to i step 1 if (cards(j)=z) and (k=0) then k=1 next j if k=1 then goto looper cards(i)=z i=i+1 endwhile endfunction |