• fullscreen
  • Pelejemplo.pde
  • clases_y_array.pde
  • /*Eduardo Hdz Obieta
    LAAd. Laboratorio de Arte, Arquitectura y Diseño.
    www.laad.com.mx*/
    
    class Pelejemplo {
    
      float x,y,x2,y2;
      float velX, velY, vel2X, vel2Y;
      float radio, radio2;
      color c[];
    
      Pelejemplo() {
        x=random(0,width);
        y=random(0,height);
        x2=random(0,width);
        y2=random(0,height);
        velX=random(1,5);
        velY=random(1,5);
        vel2X=random(3,8);
        vel2Y=random(3,8);
        radio=random(2,30);
        radio2=random(2,30);
        c=new color[n];
        for (int i=0;i<n;i++) {
          c[i]=color(random(1,255),random(1,255),random(1,255),random(0,100));
        }
      }
    
      void update() {
        if (radio > 4) {
          radio-=0.3f;
        }
    
        x=x+velX;
        y=y+velY;
        x2=x2+vel2X;
        y2=y2+vel2Y;
    
        if((x>width)||(x<0)) {
          velX=velX*-1;
          radio=20;
        }
    
        if((y>height)||(y<0)) {
          velY=velY*-1;
          radio=20;
        }
        if((x2>width)||(x2<0)) {
          vel2X=vel2X*-1;
          radio2=40;
        }
    
        if((y2>height)||(y2<0)) {
          vel2Y=vel2Y*-1;
          radio2=40;
        }
      }
    
      void draw() {
    
    
        noFill();
        strokeWeight(4);
        stroke(0,60,80,random(50,80));
        ellipse(x,y,radio,radio);
    
        strokeWeight(1);
        stroke(255,random(60,80));
        ellipse(x,y,radio,radio);
        for (int i=0; i<n; i++) {
          fill(c[i],80);
        }
        ellipse(x,y,radio,radio);
        fill(0,80,150,35);
        ellipse(x,y,radio*0.7,radio*0.7);
        noFill();
        strokeWeight(2);
        ellipse(x2,y2,radio2,radio2);
        for (int i=0; i<n; i++) {
          fill(c[i],100);
        }
        ellipse(x2,y2,radio2*0.8,radio2*0.8);
      }
    }
    
    
    /*Eduardo Hdz Obieta
    LAAd. Laboratorio de Arte, Arquitectura y Diseño.
    www.laad.com.mx*/
    
    Pelejemplo[] pel1, pel2;
    int n=20;
    
    void setup() {
      size (1000,618); 
      background(0);
      pel1=new Pelejemplo[n];
      pel2=new Pelejemplo[n];
      ellipseMode(RADIUS);
    
      for(int i=0;i<n;i++) {
        pel1[i]= new Pelejemplo();
        pel2[i]= new Pelejemplo();
      }
    }
    
    void draw() {
      fill(0);
      rect(0,0,width,height);
    
      for (int i=0; i<n; i++) {
    
        pel1[i].update();
        pel1[i].draw();
        pel2[i].update();
        pel2[i].draw();
      }
    }
    
    

    code

    tweaks (0)

    about this sketch

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

    license

    advertisement

    Eduardo Obieta

    Clases y array

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

    You need to login/register to comment.