Sep 22, 2010
Bouncing Rect
void setup (){
size(400, 400);
}
int x_position = 0;
int y_position = 0;
int x_speed = 4;
int y_speed = 2;
boolean x_richtung = false;
boolean y_richtung = false;
void draw(){
background(150);
if(x_richtung == true){ x_position -= x_speed; }
if(x_richtung == false){ x_position += x_speed; }
if(y_richtung == true){ y_position -= y_speed; }
if(y_richtung == false){ y_position += y_speed; }
if(x_position > 350){ x_richtung = true; }
if(x_position < 0){ x_richtung = false; }
if(y_position > 350){ y_richtung = true; }
if(y_position < 0){ y_richtung = false; }
rect(x_position, y_position, 50, 50);
}