• fullscreen
  • class.pde
  • motion_balls_opp.pde
  • class Orbit {
      //data
    
      float theta;
      int r;
      int r2;
      float t;
    
      //constructor
    
      Orbit (float tempTheta, int tempR, int tempR2, float tempT) {
        theta=tempTheta;
        r=tempR;
        r2= tempR2;
        t= tempT;
      }
    
      void move() {
    
        // orbiting circle
    
    
          ellipse (width/2 + cos(theta)*r2, height/2 + sin(theta)*r2, r, r);
    
    
        //increment theta
        //increase to speed up movement
    
        theta += .05;
    
    
        if (r<width-20) {
          r++;
        }
        else {
          r=r*-1;
        }
      }
    }
    
    
    //declare
    
    Orbit orbit1;
    Orbit orbit2;
    Orbit orbit3;
    Orbit orbit4;
    
    
    void setup () {
      size (400, 400);
      smooth();
    
      orbit1 = new Orbit (PI, 20, 150, .05);
      orbit2 = new Orbit (0, 20, 150, .1);
    
    }
    
    void draw () {
      background (0);
      // orbiting circle
      fill (0,250,0);
      orbit1.move();
      fill (250,0,0);
      orbit2.move();
    
    }
    
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    Robson Augusto Carlini

    Motion Balls OPP

    Add to Faves Me Likey@!
    You must login/register to add this sketch to your favorites.

    You need to login/register to comment.