A single column of squares
in
Programming Questions
•
4 months ago
Hi all,
I am new to processing and relatively new to coding. I am working through the examples on the site and have adapted one to try and learn from it.
I would like to draw a single column of squares. I am currently getting the error 'invalid token: int' referring to the first couple of lines. What do you think? Thanks!
------
//number of colums and rows
int cols = 1
int rows = 10
void setup() {
size(200,200);
grid = new Cell[cols][rows];
for (int i = 0; i < cols; i++) {
for (int j = 0; j < rows; j++) {
// Initialize each object
grid[i][j] = new Cell(i*20,j*20,20,i+j);
}
}
}
void draw() {
background(55);
for (int = 0; i < cols; i++) {
for (int j= 0; j < rows; j++) {
grid[i][j].display();
}
}
}
// A Cell object
class Cell {
// knows location and size
float x,y;
float w,h;
// Constructor
Cell(float _x, float _y, float _w, float _h) {
x = _x;
y = _y;
w = _w;
h = _h;
}
void display() {
stroke(255);
fill(0)
rect (x,y,w,h);
}
}
--------
1