Hi,
I'm doing a beginner course on processing at the moment, and I cant for the life of me get the for loop to do what I want it to do!
I'm building a simple game where boxes drop from the top the screen, and when they hit objects at the bottom, a sound is played.. sounds simple.. but I'm start at step 1
I can get the boxed to drop using an Array, but I'm having to write a line of code to specify each array, every time I try a for loop, it doesn't work
Can anyone show me how to convert the repetitive code into a loop correctly?
When a box reaches 70 px, then next box is draw... I just want them to fall continuously (a bit like Tetris)
Thanks!
here is my code that work so far:
PImage bg;
int [] rectY;
void setup() {
size(720, 1280);
// The background image must be the same size as the parameters
// into the size() method. In this program, the size of the image
// is 720 x 1280 pixels.
bg = loadImage("LED2.jpg");
rectY = new int [20];
}
void draw() {
background(bg);
rect(30, rectY[0],55, 55);
rectY[0]++;
if(rectY[0]>70){
rect(30, rectY[1],55, 55);
rectY[1]++;
}
if(rectY[1]>70){
rect(30, rectY[2],55, 55);
rectY[2]++;
}
if(rectY[2]>70){
rect(30, rectY[3],55, 55);
rectY[3]++;
}
}
1