simple animation in P3D

edited November 2013 in How To...

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

Sign In or Register to comment.