I am trying to make a game like doodle jump. But I am having a very big problem with for loops and the rect() function.
in the game rectangle that represents the player will stay still and the rectangles that you jump on will move. I have one for loop making the rectangles go down the for 400 pixels then come back up for 50 to give the effect that you jumped.
The problem is that the two for loops are running at the same time instead of one running after the other. Can someone please help me. I am only a beginner so please make it simple. Here is my code so far its not much because I'm trying to stop the loops running inside each other.
void setup() {
size(700,700);
}
float objectX = 350;
int playerX = 350;
int objectY = 0;
void draw() {
for (int i = 0; i<400;i++) {
background(204);
objectY--;
rect(objectX, objectY, 50,10 );
rect(playerX,350,10,10);
}
for (int i = 0; i<450;i++) {
background(204);
objectY++;
rect(objectX, objectY, 50,10 );
rect(playerX,350,10,10);
}