for loop between setup() and draw()
in
Programming Questions
•
2 years ago
if i use a for loop to fill a load of variables between setup() and draw() i get the error 'expecting EOF, found for'.
void setup() {
etc...
}
int NUMBER_OF_BULLETS = 2;
boolean[]keys=new boolean[5];
int[]bullet_pos=new int[NUMBER_OF_BULLETS];
int playerx=200;
int playery=350;
//define starting positions for bullets
for(int i=0; i<NUMBER_OF_BULLETS*2; i++){
bullet_pos[i]=playerx;
bullet_pos[i+1]=playery;
}
draw(){
etc...
}
Why can i define integers and use functions like keyPressed() between setup and draw, but apparently not a for loop?
1