I wrote this, but i cant seem to get the rectangle to start over again. If you visualize this as a road, I want the rectangle to change back to the bottom lane after it goes out of bounds in the top lane. I realise that putting:
if (x > width){
x=x2;
y=y2;
speed=speed2;
}
screwed everything up, but I can't think of an alternative.