the browser killed my long answer.....
now I write again...
saving it more often and editing it then....
AD 1)
for shuffle use at the end of setup()
- // Generate a list of random indices
- // http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
- // inside-out algorithm
- for (int i = 1; i < positions.length; i++)
- {
- int j = int(random(0, i+1));
- swapPositions(i, j);
- }
or longer
- // Generate a list of random indices
- // http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
- // inside-out algorithm
- for (int i = 1; i < positions.length; i++)
- {
- int j = int(random(0, i+1));
- int dummy = positions[i];
- positions[i] = positions[j];
- positions[j] = dummy;
- }
AD 2)
here
- PImage small, img = loadImage("d3s.jpg");
better say
- PImage small;
- PImage img = loadImage("d3s.jpg");
d3s.jpg must be in data folder , I think
exact spelling of d3s, upper case / lower case correct? Also for jpg/JPG?
AD 3)
that's part of the swapping process.
You want to swap two elements of the array positions
the elements are in line a and b
since swap is called in line 38 above we get different values for a and b by your mouse click.
swapping:
- int temp = positions[a]; // put the value in my list positions in row a into temp
- positions[a] = positions[b]; // put the value in my list positions in row b into list, row a
- positions[b] = temp; //put the value of temp (which was positions[a]) in my list positions in row b
swapping complete!
Since we overwrite values we need temp to store the old value.
Remark
The = is not an equation but a command saying "put the value of the right side variable into the left side variable"
leftsidevariable = rightsidevariable;
Test it:
(this is a full functioning program, not a part of your puzzle program)
- int a = 3+5;
- println (a);
or
(this is a full functioning program)
- int a = 4;
- println ( a ) ;
- int b = 5;
- a = b;
- println ( a ) ;
prints 4, then 5
Greetings, Chrisir