Help with reciprocating rect loop
in
Programming Questions
•
1 year ago
Hi,
I am a noob in processing, and I need a help in reciprocating a block in a loop. I have implemented it. But wanna know if there is any code simpler than this!.
The receiprocation must be in a loop (like the piston in crank slider mechanism).
- here is the code what i tried:
int x=300,y=0;
void setup(){
size(640,320);
}
void draw(){
background(0,0,y);
rect(x,200,30,70);
if(y<100)
x++;
y++;
if(y>=100){
x--;}
if(y>200){
y=0;
x=300;}
}
is there any simple way to do it?
Thanks for your help.
1