Hi, I’m writing some code for a animation project and I want to let ellipses move around a sun. I have four ellipses that move four times around the sun and I want to let them move around when you press the up or the down key. With the code I have right now, I’m not only moving the ellipses around the sun but the whole city. (There might be some dutch words in my code that I used as comments or as function names).
1 Like
[https://processing.org/reference/ellipseMode_.html]
[https://processing.org/reference/pushMatrix_.html]
void draw(){
background(255);
pushMatrix();
translate(width/2, height/2);
ellipseMode(CENTER);
rotate(radians(angle));
roundSun();
popMatrix();
fill(#FFF7AF);
ellipse (30, 30, 100, 100);
}
void keyPressed(){
if(keyCode == UP){
angle--;
} else if(keyCode == DOWN){
angle++;
}
}
Push, Pop helps when you want to move alot at once, kinda like grouping shapes together. I did end up placing the main sun body in the draw and kept the rays with the void draw, so just the rays rotate around the main ellipse when pressing the button.
See if this helps, hope I read the question correctly
1 Like
Yes, thank you soo much!!
I had to change a few things but I finally managed to only rotate the rays of the sun.
Again, thanks for your help
1 Like