dimanche 22 février 2015

Need Processing assistance. If statement

Can someone help me with my code. I am trying to get the square to appear on the left side of the window again once it moves off the right side. I almost have it, but once it goes off the right side, it suddenly appears on the left side. I need help making it appear smoothly on the left side of the screen.


Here is my code.



float x = 0;
void setup() {
size(200,200);
}
void draw() {
background(255);
drawRect();
if(x > width+5) {
x = 0;
}
}
void drawRect() {
fill(0);
for (int i = 0; i<width; i+=15){
rect(x +i*2,100,20,20);
}
x = x + 1;
}

Aucun commentaire:

Enregistrer un commentaire