Gallery

I should think there is an array that contains all the possible locations a square could be placed. Then, every so often, or when you click on something, a script selects a random number between zero and the amount of values in the array. It then gradually moves a square to that position.

It might actually be an associative array that also contains whether or not a position is currently occupied by another square.

Either way, that’s how it’s done.