|
ClassWork / Icm-snippets
Bouncing Ball
int xpos ;
int diam = 30;
int dir = 1;
int speed = 1;
void setup(){
//hi
size(329,480);
frameRate(300);
xpos = 0;
}
void draw(){
//speed = mouseY/100;
background(127);
ellipse(xpos,100, diam,diam); //move the ball
if (xpos >= width - diam/2){
dir = -1;
}
if (xpos <= 0 + diam/2){
dir = 1;
}
xpos = xpos + dir*speed;
println(xpos);
}
|