We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I want to make a simple animation in P3D. My code right now generates an ellipse that moves inside the borders of the sketch size, my goal is to transform the ellipse into a sphere that does the same. I know how to create the sphere in a P3D environment but I can't seem to make it move.
this is my current code:
float x = 100;
float y = 100;
float xspeed = 1;
float yspeed = 3.3;
void setup() {
size(640,360);
background(255);
}
void draw() {
background(255);
x = x + xspeed;
y = y + yspeed;
if ((x > width) || (x < 0)) {
xspeed = xspeed * -1;
}
if ((y > height) || (y < 0)) {
yspeed = yspeed * -1;
}
stroke(0);
fill(175);
ellipse(x,y,16,16);
}
Answers
Have you already looked at sphere() reference??? :(|)
http://processing.org/reference/sphere_.html
Thanks for the answer. Yeah I did. My problem is to generate movement to the sphere, not to generate the sphere itself. I understand I need to change the 'size' to size(640,360,P3D), and instead of ellipse add translate() and sphere(). Is there anything else that requires modification to the code?
Barely know anything 'bout it. But I've got this online example below: <):)
http://studio.processingtogether.com/sp/pad/export/ro.9o1T5z1ghf2s7/latest
Got it, thanks! I wrote translate(x,y) right before ellipse() and it worked :-)