### 2d matrix transformation (with 2d array) [newbie]

##### Answered

- Need more info
- Answered
- Working on it

Hi

I'm working with a 2d array of points to draw a 2d "grid" of points, to get something like this:

00000

00000

00000

00000

then I feed the array so i can have some figures inside it, like this

00000

00110

01100

00000

and I'm trying to translate the info of the array so I can move the figure to the left, like this

00000

11000

10001

00000

doing this: (the matrix is 10 x 10 circles, each one size 18)

- void moveLeft() {
- int trans = 20;
- for (int i = 10; i <= 190; i = i+trans) {
- for (int j = 10; j <= 190; j = j+trans) {
- int cont = i;
- if (matrix[i][j] == 1) {
- if (i <= 10) {
- cont = cont + 200;
- }
- matrix[cont-trans][j] = 1;
- fill(50);
- ellipse(i,j,18,18);
- matrix[i][j] = 0;
- }
- }
- }
- }

the problem is that the first time I apply the function moveLeft() the circles are redrawn in the same location, only the second time it changes position, and the when I apply moveUp() [similar function, but working with j ] the circles move left first and then up... I can't get why!!! Any help?

The other problem is I can't figure out how to move the circles to the other side, I mean Right and Down... it should be easy but I cant find the way.

Thanks a lot

1