| **Set an initial position then randomize X and Y**
on Jun 15, 2017 at 1:38:21 am |

Hello! I'm new to expressions. I got a comp which is 850x850px, got a grid so that each square is 85x85px (so it is 10 rows, 10 columns). I got a layer for each square and I want them to switch between them randomly, like a puzzle, I don't mind if they overlap, but I want them to move just in 85px multiples.

I searched and combined some expressions i found and got an expression which I post.

Which makes them move but not in 85px multiples, how do I make it so I can set a position start and then move it from there in 85px multiples?

`holdTime = .1; `

seed = Math.floor(time/holdTime);

seedRandom(seed,true);

xPositions = Math.round(random(1,85));

yPositions = Math.round(random(1,85));

a = Math.round(random(1,10));

b = Math.round(random(1,10));

x = xPositions*a;

y = yPositions*b;

[x,y]

| **Re: Set an initial position then randomize X and Y** on Jun 15, 2017 at 5:58:28 am |

Maybe something like this:

holdTime = .1;

seed = Math.floor(time/holdTime);

if (seed > 0){

seedRandom(seed,true);

col = Math.floor(random(10));

row = Math.floor(random(10));

origin = [85,85]/2;

origin + [col,row]*85

}else

value

It will stay in its initial position for the first holdTime, then move randomly.

Dan