I changed your code a bit. Check it out:
Code:Block[] blocks = new Block[0];
void setup() {
background(0);
stroke(255);
size(600, 600);
}
class Block {
int weight = 1;
float side = 10;
float xPos;
float yPos;
Block(int _xPos, int _yPos) {
xPos = _xPos;
yPos = _yPos;
rect(xPos, yPos, side, side);
}
void drawBlock() {
rect(xPos, yPos, side, side);
}
void fall() {
}
}
void mouseClicked() {
append(blocks, new Block(mouseX, mouseY));
}
void draw() {
for(int c = 0; c < blocks.length; c++){
Block b=blocks[c];
b.drawBlock();
}
}
you had a global iterator "i" which is unnecessary. You can just find the length of your array and iterate using a local iterator (as i did in draw()).
furthermore, array items have to be explicitly initialized, otherwise they are null, and therefore contain no variables. That's why your "created" variable couldn't be seen.
the append(array, object) function is processing-specific. Generally it is not an easy (or good) practice appending stuff to arrays. You could use ArrayLists which are much more flexible. Check out the reference, it is documented there.