Array loop help Please
in
Programming Questions
•
2 years ago
We have to do 50 lines of stars directly under one another like on the flag, so i did three loops and for some reason the stars are coming out diagonal? help?
//arrays holding x and y coordinates for star
void draw(){
int[] x = {50, 61, 83, 69, 71, 50, 29, 31, 17, 39};
int[] y = { 18, 37, 43, 60, 82, 73, 82, 60, 43, 37 };
smooth();
int j=0; //integer for the number of stars produced
int l=0; //increases the x values
int k=0;//increases the y values while(j<500){
while (k<100) {
beginShape();
for (int i = 0; i < x.length; i++) {
x[i]=x[i]+k;
y[i]=y[i]+l;
vertex(x[i], y[i]);
}
k=k+10;
endShape(CLOSE);
}
l=l+10;
k=0;
j=j+1;
}
}
1