Friday, November 27, 2009

Shuffle Board



Ah, simplicity...

I sat down today and wanted to whip this up. After a couple hours, I realized I was getting nowhere. I was approaching this completely backwards. See, originally I intended to keep an array of the x and y coordinates of each dot. THEN, I wanted to shuffle each of those arrays around and assign them to the dots. This turned into a huge hassle, as I realized by completely shuffling them, you always had some overlap (it was possible to have several dots in the same location). SO, I tried to store each x and y coordinate as a pair into an array. That sort of worked, but based on how I originally added the movie clips to the stage, I could only truly randomize either the rows or the columns. Everything moved in this case, but if all columns were randomized, then all rows would move together as a group.

So then it hit me. Don't shuffle the coordinates. Shuffle the DOTS! Duh! If I would have approached this from that perspective at the beginning, this would have taken minutes rather than hours.

Source files:
scrambleDots.fla
Scrambler.as

No comments:

Post a Comment