Setting Time Constraints
in
Programming Questions
•
1 year ago
Hey, I have been working on some code with moving rectangles and I need to set time constraints for each method but as I am new to processing I can't figure it out! Maybe it is not possible to add this to my code? Each method needs to be carried out within a certain time frame. Can anyone help?
here is my code:
int moveX, moveY, moveA, moveB;
void setup() {
moveX = 0;
moveY = 799;
moveA = 0;
moveB = 0;
size(800, 800);
}
void moveLeft() {
fill(0);
rect(moveX, height/3, 40, 20);
moveX++;
if (moveX >= 700) {
moveX = 700;
}
}
void moveRight() {
fill(0);
rect(moveY, 400, 40, 20);
moveY--;
if (moveY <= 200) {
moveY = 200;
}
}
void moveBottom() {
fill(0);
rect(200, 400, 20, moveA );
moveA++;
if (moveA >= 160) {
moveA = 160;
}
}
void moveTop() {
fill(0);
rect(720, 0, 20, moveB );
moveB++;
if (moveB >= height/3) {
moveB = height/3;
}
}
void draw() {
moveLeft();
if (moveX >= 500) {
moveRight();
if (moveY <= 200)
moveBottom();
if (moveA >= 140)
moveTop();
}
}
1