# Problems with translate

**URL:** <https://discourse.processing.org/t/problems-with-translate/20952>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [May 16, 2020, 8:03pm UTC](https://discourse.processing.org/t/problems-with-translate/20952 "2020-05-16T20:03:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![valeria0616](https://avatars.discourse-cdn.com/v4/letter/v/ce73a5/32.png) [@valeria0616](https://discourse.processing.org/u/valeria0616)\
**Post date:** [May 16, 2020, 8:03pm UTC](https://discourse.processing.org/t/problems-with-translate/20952/1 "2020-05-16T20:03:29Z")

</div>

Hi everyone, i’m really new to processing, and I have a project that consists on doing something in 3d, so I was trying to draw the Starry Night and add the stars and houses with spheres that rotate and boxes, but when I use translate just one object moves and all the other ones dissapear apparently? I don’t really know what I’m doing wrong and I was hoping someone could help me please. This is what I currenty have:(

```auto
float x=0.0;
int y=0;

void setup(){
  size(800,600,P3D);
  background(33,55,130);
}
  void draw(){
    
    //sky
  strokeWeight(20);
  strokeCap(ROUND);
  stroke(129,186,205);
    line(0,100,150,80);
line(150,80,x*2,85);
x=x+0.5;
line(190,85,300,90);
line(300,90,400,120);
line(400,120,500,130);
line(500,130,600,140);
line(600,140,700,160);
line(600,140,x*2,160);
line(700,160,800,130);
stroke(29,31,44);
strokeWeight(5);
line(800,50,x*2,160);
stroke(221,218,201);
strokeWeight(5);
line(800,40,x*.5,130);
     stroke(29,31,44);
   line(800,300,x*2,200);
   stroke(56,100,103);
   line(x*2,350,400,200);
   stroke(55,105,200);
   line(x,300,x*2, 200);
   stroke(129,186,205);
   line(x*2,300,500,200);

//mountains
fill(120,148,170);
noStroke();
ellipse(100,550,200,100);
fill(50,70,77);
ellipse(0,600,300,150);
fill(18,18,30);
ellipse(300,600,400,120);
fill(33,60,127);
ellipse(800,600,800,120);

  //tree
    fill(10);
strokeWeight(2);
stroke(5);
beginShape();
vertex(250,750);
vertex(225,700);
vertex(250,650);
vertex(235,600);
vertex(260,400);
vertex(257,350);
vertex(265,370);
vertex(270,350);
vertex(267,270);
vertex(259,250);
vertex(265,200);
vertex(272,250);
vertex(278,260);
vertex(280,275);
vertex(284,350);
vertex(290,400);
vertex(310,500);
vertex(315,470);
vertex(320,500);
vertex(330,550);
vertex(325,480);
vertex(335,460);
vertex(345,490);
vertex(356,500);
vertex(360,525);
vertex(375,550);
vertex(375,580);
vertex(393,650);
vertex(387,750);
vertex(250,750);
endShape(CLOSE);
 
  //stars
 
  fill(75,142,169);
translate(700,100,0);
sphere(30);
    
    translate(500,200,0);
    sphere(20);
    
    }

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 16, 2020, 8:06pm UTC](https://discourse.processing.org/t/problems-with-translate/20952/2 "2020-05-16T20:06:05Z")

</div>

Hello,

Please format your code:  
[https://discourse.processing.org/faq#format-your-code](https://discourse.processing.org/faq#format-your-code)

> **Resources \< Click here to expand !**
>
> I encourage you to review the resources available here:
> 
> - The Processing website has references, examples, tutorials, etc.  
> [https://processing.org/](https://processing.org/)
> - Those available with the Processing PDE (IDE).  
> An exploration of the tabs will reveal what is available; there are libraries and examples there.
> - The Coding Train  
> [https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1\_aw](https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1_aw)  
> [https://thecodingtrain.com/](https://thecodingtrain.com/)
> - Happy Coding  
> [Processing Tutorials - Happy Coding](https://happycoding.io/tutorials/processing/)
> - The Processing Foundation  
> [https://processingfoundation.org/](https://processingfoundation.org/)  
> Check out the tabs.  
> In the education tab, there is a reference to the Coding Train.

`:)`

---

<div class="post-metadata">

**Author:** ![valeria0616](https://avatars.discourse-cdn.com/v4/letter/v/ce73a5/32.png) [@valeria0616](https://discourse.processing.org/u/valeria0616)\
**Post date:** [May 16, 2020, 8:23pm UTC](https://discourse.processing.org/t/problems-with-translate/20952/3 "2020-05-16T20:23:31Z")

</div>

```auto
float x=0.0;
int y=0;

void setup(){
  size(800,600,P3D);
  background(33,55,130);
}
  void draw(){
    
    //sky
  strokeWeight(20);
  strokeCap(ROUND);
  stroke(129,186,205);
    line(0,100,150,80);
line(150,80,x*2,85);
x=x+0.5;
line(190,85,300,90);
line(300,90,400,120);
line(400,120,500,130);
line(500,130,600,140);
line(600,140,700,160);
line(600,140,x*2,160);
line(700,160,800,130);
stroke(29,31,44);
strokeWeight(5);
line(800,50,x*2,160);
stroke(221,218,201);
strokeWeight(5);
line(800,40,x*.5,130);
     stroke(29,31,44);
   line(800,300,x*2,200);
   stroke(56,100,103);
   line(x*2,350,400,200);
   stroke(55,105,200);
   line(x,300,x*2, 200);
   stroke(129,186,205);
   line(x*2,300,500,200);

   

//mountains
fill(120,148,170);
noStroke();
ellipse(100,550,200,100);
fill(50,70,77);
ellipse(0,600,300,150);
fill(18,18,30);
ellipse(300,600,400,120);
fill(33,60,127);
ellipse(800,600,800,120);

    
    //tree
    fill(10);
strokeWeight(2);
stroke(5);
beginShape();
vertex(250,750);
vertex(225,700);
vertex(250,650);
vertex(235,600);
vertex(260,400);
vertex(257,350);
vertex(265,370);
vertex(270,350);
vertex(267,270);
vertex(259,250);
vertex(265,200);
vertex(272,250);
vertex(278,260);
vertex(280,275);
vertex(284,350);
vertex(290,400);
vertex(310,500);
vertex(315,470);
vertex(320,500);
vertex(330,550);
vertex(325,480);
vertex(335,460);
vertex(345,490);
vertex(356,500);
vertex(360,525);
vertex(375,550);
vertex(375,580);
vertex(393,650);
vertex(387,750);
vertex(250,750);
endShape(CLOSE);
 
 
 //stars
 
  fill(75,142,169);

translate(700,100,0);
sphere(30);
    
    translate(500,200,0);
    sphere(20);
     
}

```

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [May 16, 2020, 9:01pm UTC](https://discourse.processing.org/t/problems-with-translate/20952/4 "2020-05-16T21:01:10Z")

</div>

Please use the pencil below the code of your two posts. Then select everything and delete it.  
Paste your code again and select exactly and only the code. Then press the \</\> button.  
There is no x2 declared in your code. Also you can’t use x.5.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 16, 2020, 11:14pm UTC](https://discourse.processing.org/t/problems-with-translate/20952/5 "2020-05-16T23:14:24Z")

</div>

Hello,

I posted some resources for you before to explore in my previous post.

The rest is you and your imagination.

And some work on your part learning how to use the tools.

I only tweaked your code a bit and made some comments.

> **Code**
>
> ```auto
> float x=0.0;
> int y=0;
> 
> void setup() 
> {
> size(800, 600, P3D);
> background(33, 55, 130);
> }
> 
> void draw() 
> {
> background(33, 55, 130);
> lights(); // :) 
> //sky
> strokeWeight(20);
> strokeCap(ROUND); // Does NOT work in P3D
> stroke(129, 186, 205);
> line(0, 100, 150, 80);
> line(150, 80, x*2, 85);
> x=x+0.5;
> line(190, 85, 300, 90);
> line(300, 90, 400, 120);
> line(400, 120, 500, 130);
> line(500, 130, 600, 140);
> line(600, 140, 700, 160);
> line(600, 140, x*2, 160);
> line(700, 160, 800, 130);
> stroke(29, 31, 44);
> strokeWeight(5);
> line(800, 50, x*2, 160);
> stroke(221, 218, 201);
> strokeWeight(5);
> line(800, 40, x*.5, 130);
> stroke(29, 31, 44);
> line(800, 300, x*2, 200);
> stroke(56, 100, 103);
> line(x*2, 350, 400, 200);
> stroke(55, 105, 200);
> line(x, 300, x*2, 200);
> stroke(129, 186, 205);
> line(x*2, 300, 500, 200);
> 
> //mountains
> fill(120, 148, 170);
> noStroke();
> ellipse(100, 550, 200, 100);
> fill(50, 70, 77);
> ellipse(0, 600, 300, 150);
> fill(18, 18, 30);
> ellipse(300, 600, 400, 120);
> fill(33, 60, 127);
> ellipse(800, 600, 800, 120);
> 
> //tree
> fill(0, 255, 0);
> strokeWeight(2);
> stroke(5);
> beginShape();
> vertex(250, 750);
> vertex(225, 700);
> vertex(250, 650);
> vertex(235, 600);
> vertex(260, 400);
> vertex(257, 350);
> vertex(265, 370);
> vertex(270, 350);
> vertex(267, 270);
> vertex(259, 250);
> vertex(265, 200);
> vertex(272, 250);
> vertex(278, 260);
> vertex(280, 275);
> vertex(284, 350);
> vertex(290, 400);
> vertex(310, 500);
> vertex(315, 470);
> vertex(320, 500);
> vertex(330, 550);
> vertex(325, 480);
> vertex(335, 460);
> vertex(345, 490);
> vertex(356, 500);
> vertex(360, 525);
> vertex(375, 550);
> vertex(375, 580);
> vertex(393, 650);
> vertex(387, 750);
> vertex(250, 750);
> endShape(CLOSE);
> 
> //stars 
> push(); 
> fill(75, 142, 169); //Look up push() and pop()
> translate(700, 100, 0);
> noStroke();
> sphere(30);
> pop();
>   
> // Work on this...
> translate(500, 200, 0);
> sphere(20);
> }
> 
> ```

`:)`
