Hi:)
this is my code:
**Edit - I tried to change to color of the block in the display function , and it stays black... I cant find the problem ..
- Block[][] grid;
- int cols = 16;
- int rows =10;
- void setup()
- {
- size(800,500);
- grid = new Block[cols][rows];
- for(int x = 0;x<cols;x++)
- {
- for(int y = 0;y<rows;y++)
- {
- grid[x][y] = new Block(x*50,y*50,50,50);
- }
- }
- }
- void draw()
- {
- for(int x = 0;x<cols;x++)
- {
- for(int y = 0 ;y<rows;y++)
- {
- grid[x][y].display();
- }
- }
- }
- class Block
- {
- int x,y,w,h,xEnd,yEnd;
- boolean clicked;
- Block(int xx,int yy,int ww,int hh)
- {
- clicked = false;
- x = xx;
- y = yy;
- w = ww;
- h =hh;
- xEnd = x+50;
- yEnd = y+50;
- }
- void display()
- {
- if(clicked = false)
- {
- fill(color(255));
- rect(x,y,w,h);
- }
- else if(clicked = true)
- {
- fill(color(0));
- rect(x,y,w,h);
- }
- }
- void changeColor()
- {
- if(clicked = false)
- {
- clicked = true;
- }
- else if(clicked = true)
- {
- clicked = false;
- }
- }
- }
- void mouseClicked()
- {
- moveToBlock(mouseX,mouseY);
- }
- void moveToBlock(int mX,int mY)
- {
- for(int x = 0;x<cols;x++)
- {
- for(int y = 0 ;y<rows;y++)
- {
- if(mX > grid[x][y].x && mX < grid[x][y].xEnd)
- {
- if(mY > grid[x][y].y && mY<grid[x][y].yEnd)
- {
- grid[x][y].changeColor();
- }
- }
- }
- }
- }
please help me

(Sorry for my English ...)
1