thank you, why do i get ArrayIndexOutOfBoundsException: 10?
float[] blockx= new float[10];
float[] blocky= new float[10];
float timeneeded= 3000;
int i=1;
void setup() {
size(400, 300);
blockx[1]= 0;
blocky[1]=0;
}
void draw() {
background(127);
if (blocky[i]==200&& blockx[i] != 300) {
i++;
}
if (blocky[i]==200&& blockx[i] == 300) {
blockx[i]= 0;
blocky[i]=0;
}
if(blockx[i]==blockx[1]&&blocky[i]==blocky[1]-100){
i++;}
if(blockx[i]==blockx[2]&&blocky[i]==blocky[2]-100){
i++;}
if(blockx[i]==blockx[3]&&blocky[i]==blocky[3]-100){
i++;}
if(blockx[i]==blockx[4]&&blocky[i]==blocky[4]-100){
i++;}
if(blockx[i]==blockx[5]&&blocky[i]==blocky[5]-100){
i++;}
if(blockx[i]==blockx[6]&&blocky[i]==blocky[6]-100){
i++;}
if(blockx[i]==blockx[7]&&blocky[i]==blocky[7]-100){
i++;}
if(blockx[i]==blockx[8]&&blocky[i]==blocky[8]-100){
i++;}
if(blockx[i]==blockx[9]&&blocky[i]==blocky[9]-100){
i++;}
if (frameCount%120 == 0) {
blocky[i]=blocky[i]+100;
}
if (keyPressed&&blockx[i]<300) {
if (key=='d') {
blockx[i]=blockx[i]+100;
}
}
if (keyPressed&&blockx[i]>0) {
if (key=='a') {
blockx[i]=blockx[i]-100;
}
}
fill(255);
rect(blockx[i], blocky[i], 100, 100);
if(i==2){
rect(blockx[1], blocky[1], 100, 100);
}
if(i==3){
rect(blockx[1], blocky[1], 100, 100);
rect(blockx[2], blocky[2], 100, 100);
}
if(i==3){
rect(blockx[1], blocky[1], 100, 100);
rect(blockx[2], blocky[2], 100, 100);
rect(blockx[3], blocky[3], 100, 100);
}
if(i==4){
rect(blockx[1], blocky[1], 100, 100);
rect(blockx[2], blocky[2], 100, 100);
rect(blockx[3], blocky[3], 100, 100);
rect(blockx[4], blocky[4], 100, 100);
}
if(i==5){
rect(blockx[1], blocky[1], 100, 100);
rect(blockx[2], blocky[2], 100, 100);
rect(blockx[3], blocky[3], 100, 100);
rect(blockx[4], blocky[4], 100, 100);
rect(blockx[5], blocky[5], 100, 100);
}
if(i==6){
rect(blockx[1], blocky[1], 100, 100);
rect(blockx[2], blocky[2], 100, 100);
rect(blockx[3], blocky[3], 100, 100);
rect(blockx[4], blocky[4], 100, 100);
rect(blockx[5], blocky[5], 100, 100);
rect(blockx[6], blocky[6], 100, 100);
}
if(i==7){
rect(blockx[1], blocky[1], 100, 100);
rect(blockx[2], blocky[2], 100, 100);
rect(blockx[3], blocky[3], 100, 100);
rect(blockx[4], blocky[4], 100, 100);
rect(blockx[5], blocky[5], 100, 100);
rect(blockx[6], blocky[6], 100, 100);
rect(blockx[7], blocky[7], 100, 100);
}
if(i==8){
rect(blockx[1], blocky[1], 100, 100);
rect(blockx[2], blocky[2], 100, 100);
rect(blockx[3], blocky[3], 100, 100);
rect(blockx[4], blocky[4], 100, 100);
rect(blockx[5], blocky[5], 100, 100);
rect(blockx[6], blocky[6], 100, 100);
rect(blockx[7], blocky[7], 100, 100);
rect(blockx[8], blocky[8], 100, 100);
}
if(i==9){
rect(blockx[1], blocky[1], 100, 100);
rect(blockx[2], blocky[2], 100, 100);
rect(blockx[3], blocky[3], 100, 100);
rect(blockx[4], blocky[4], 100, 100);
rect(blockx[5], blocky[5], 100, 100);
rect(blockx[6], blocky[6], 100, 100);
rect(blockx[7], blocky[7], 100, 100);
rect(blockx[8], blocky[8], 100, 100);
rect(blockx[9], blocky[9], 100, 100);
}
strokeWeight(10);
noFill();
rect(0, 0, 100, 100);
rect(100, 0, 100, 100);
rect(200, 0, 100, 100);
rect(300, 0, 100, 100);
rect(0, 100, 100, 100);
rect(100, 100, 100, 100);
rect(200, 100, 100, 100);
rect(300, 100, 100, 100);
rect(0, 200, 100, 100);
rect(100, 200, 100, 100);
rect(200, 200, 100, 100);
rect(300, 200, 100, 100);
}