What's wrong with this two dimension array?
in
Programming Questions
•
1 month ago
I want to make a grid. My code as below, it shows nothing, i have no clue how to debug
- int n=40;
- int maxX = 120;
- int maxY = 100;
- Square[][]squares = new Square[maxX][maxY];
- void setup (){
- size(480,480);
- background(0);
- smooth();
- for(int i=0;i<maxX;i++){
- for(int j=0;j<maxY;j++){
- int number=0;
- squares[i][j]= new Square(number,number,100,100,100);
- number+=n;
- }
- }
- }
- void draw(){
- for(int i=0;i<maxX;i++){
- for(int j=0;j<maxY;j++){
- squares[i][j].draw();
- }
- }
- }
- class Square{
- float x,y,a,b,c;
- boolean ok;
- Square(float ax,float ay,float aa,float ab,float ac){
- x = ax;
- y = ay;
- a=aa;
- b=ab;
- c=ac;
- ok=false;
- }
- void draw(){
- fill(a,b,c);
- stroke(255);
- rect(x,y,n,n);
- }
- }
1