xxxxxxxxxx
//let x , y
var x
var y
var changeDirection;
function setup() {
createCanvas(800, 800);
background(100);
x = 800
changeDirection = false
}
function draw() {
// rocks()
print(x)
// print(y)
stones()
}
function stones(){
background(0,10);
for (var i=0; i < 1; i++) {
s=random(10)
fill('yellow')
ellipse(x,x+s,20);
ellipse(x-50,x+s,20);
ellipse(x+70,x-s,20);
ellipse(x,y,20);
}
if(x>height){
changeDirection=true}
else if (x<=0){
changeDirection=false}
if (x>=0 && changeDirection == false){
x=x+1}
else if(changeDirection == true){
x=x-1}
}
function rocks (){
for(let i= 0;i<1;i++){
background(200);
// Draw a circle
stroke(50);
fill(100);
for(let o = 0; i < 2;i++){
ellipse(x, y, 24, 24);
}
//moving settings
x = x - random(-1, 1);
y = y + 1;
// when it touch the end it goes up
if (y > height) {
y = 0;
}
}
}