Confused with loop code
when i run my code, it makes my stick figure in the window move as well and I want him to stay in the window. The only thing I want to move across the screen is the clouds. heres the code:
PImage cloud;
float x,y;
void setup(){
size(900,900);
if (frame != null) {
frame.setResizable(true);
}
background(255);
cloud=loadImage("Clouds.png");
smooth();
}
void draw() {
//Sky
fill(158,222,255);
noStroke();
rect(0,0,900,900);
//Land
fill(178,161,100);
stroke(168,151,90);
strokeWeight(3);
rect(0,600,900,600);
//house structure & brick
fill(160,71,47);
stroke(0);
strokeWeight(1);
rect(450,450,300,300);
for(int y=450;y<750;y+=20){
for(int x=450;x<750;x+=20){
rect(x,y,20,10);
}
}
//roof
fill(0);
noStroke();
triangle(600,350,450,450,750,450);
//sidewalk
fill(168,167,173);
noStroke();
bezier(450,750,450,900,750,900,750,750);
//door
fill(2550,0,0);
stroke(255);
strokeWeight(1);
quad(550,600,550,750,650,750,650,600);
//door knob
fill(0);
noStroke();
ellipse(555,675,10,10);
//windows
fill(175,255,244);
stroke(0);
strokeWeight(1);
rect(470,490,80,80);
rect(655,490,80,80);
//window lines
line(510,490,510,570);
line(470,530,550,530);
line(695,490,695,570);
line(655,530,735,530);
//tree
fill(82,50,11);
noStroke();
rect(100,800,50,300);
fill(11,82,11);
noStroke();
ellipse(100,800,50,50);
ellipse(125,800,50,50);
ellipse(150,800,50,50);
ellipse(110,760,50,50);
ellipse(135,760,50,50);
//tree
fill(11,82,11);
stroke(11,82,11);
strokeWeight(25);
point(123,730);
//grass
for(int y=880;y<910;y+=10){
for(int x=10;x<910;x+=10){
triangle(x,y,0,900,20,900);
}
}
//sun
fill(255,247,0);
stroke(255,188,3);
strokeWeight(1);
arc(900,0,550,550,QUARTER_PI,PI+QUARTER_PI);
//clouds
x= x + 0.5;
if (x > width + 800){
x=0;
}
translate(x,0);
image(cloud,-cloud.width,10,cloud.width,cloud.height);
image(cloud,-300,0,cloud.width/2,cloud.height/2);
image(cloud,-490,40,cloud.width/1.5,cloud.height/1.5);
image(cloud,-670,30,cloud.width/2, cloud.height/2);
image(cloud,-850,5,cloud.width/1.5,cloud.height/1.5);
{
}
if(mousePressed==true){
fill(0);
stroke(0);
ellipse(490,540,20,20);
fill(0);
line(490,540,490,580);
line(490,560,500,550);
line(490,560,480,550);
}else{
fill(0);
stroke(0);
ellipse(675,540,20,20);
fill(0);
line(675,540,675,580);
line(675,560,685,550);
line(675,560,665,550);
}
}