• fullscreen
  • Eye.pde
  • Monster.pde
  • _09_0310_black_tentacle_monster_remix_web.pde
  • class Eye
    {
        float eyeSize;
        float pupilSize;
        float eyeDistance;
        float eyeX;
        float eyeY;
        float pupilX;
        float pupilY;
        float contadorX  = 0;
        float contadorY  = 0;
        Eye(float x, float y, float e)
        {
            eyeSize = 50;
            pupilSize = 20;
            eyeX = x;
            eyeY = y;
            eyeDistance = e;
            
            pupilX = eyeX;
            pupilY = eyeY;
        }
        float  addContadorX(int numero){
           contadorX= contadorX + TWO_PI/100; 
          float oscilacionX = sin(contadorX) * numero ;
         
          return oscilacionX;
        }
          float  addContadorY(int numero){
           contadorY= contadorY + TWO_PI/100; 
          float oscilacionY = sin(contadorY) * numero ;
         
          return oscilacionY;
        }
        
        void update()
        {
            float mY = map(mouseY, 0, height, -eyeSize/4, eyeSize/4);
            pupilY = eyeY + mY;
    
            float mX = map(mouseX, 0, height, -eyeSize/4, eyeSize/4);
            pupilX = eyeX + mX;
        }
        
        void draw()
        {
            // stroke around eyeball
            fill(255);
            ellipse(eyeX, eyeY, eyeSize + 10, eyeSize + 10);
            
            // eyeball
            fill(0);
            ellipse(eyeX, eyeY, eyeSize, eyeSize);
            
            
           for (int i=0;i<10;i ++){
             // pupil
            fill(map(i,0,10,100,255),0,0);
            ellipse(pupilX, pupilY, pupilSize-(i*10), pupilSize-(i*10));   
           }
        }
    }
    
    class Monster
    {
        int maxMonsterSize;
        int numEyes;
        float angle;
        
        Eye[] eyes;
    
        Monster(int nEyes, int mSize)
        {
            numEyes = nEyes;
            maxMonsterSize = mSize;
            
            angle = 360 / numEyes;
            
            eyes = new Eye[nEyes];
            
            for (int i = 0; i < numEyes; i++) {
                float eyeDistance = width/2-10;
                 //float eyeDistance = random(100, 250);
                float x = cos(radians(i*angle)) * eyeDistance;
                float y = sin(radians(i*angle)) * eyeDistance;
                eyes[i] = new Eye(x, y, eyeDistance);
            }
        }
            
        void draw()
        {
            fill(0);
           stroke(0,30);
            strokeWeight(1);
            noFill();
            float separacion = 0;
              int fuerzaX = 200;
               int fuerzaY = 550;
            for (int i = 0; i < numEyes; i++) {
                float x1 = cos(radians(i*angle)) * separacion;
                float y1 = sin(radians(i*angle)) * separacion;
                
                float cx1 = cos(radians(i*angle)) * (separacion + (eyes[i].eyeDistance/2-eyes[i].addContadorX(fuerzaX)));
                float cy1 = sin(radians(i*angle)) * (separacion + (eyes[i].eyeDistance/2-eyes[i].addContadorY(fuerzaY)));
    
                float cx2 = cos(radians(i*angle)) * (eyes[i].eyeDistance - (eyes[i].eyeDistance/2-eyes[i].addContadorX(fuerzaX)));
                float cy2 = sin(radians(i*angle));
                
                float x2 = cos(radians(i*angle)) * (eyes[i].eyeDistance );
                float y2 = sin(radians(i*angle)) * (eyes[i].eyeDistance );
                
                if (cy1 == 0.0) {
                   // cy1 = y1 + (eyes[i].eyeDistance/2-300); // stiff tentacle problem
                    // float cy1 = sin(radians(i*angle)) * (frecuencia + (eyes[i].eyeDistance/2));
                }
                
                if (cy2 == 0.0) {
                    //cy2 = y2 + (eyes[i].eyeDistance - (eyes[i].eyeDistance/2-100)); // stiff tentacle problem
                }
    
                bezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2);
            }
            noStroke();
                
            // tentacles end
            fill(0);
            for (int i = 0; i < numEyes; i++) {
                float x = cos(radians(i*angle)) * (eyes[i].eyeDistance );
                float y = sin(radians(i*angle)) * (eyes[i].eyeDistance );
                fill(255,0,0);
                ellipse(x, y, 1, 1);
            }
            
            // monster eyes
            for (int i = 0; i < numEyes; i++) {
               // eyes[i].update();
               // eyes[i].draw();
            }
            
            // monster mouth
           /* fill(255);
    
            beginShape();
            for (int i = 0; i < 30; i++) {
                float teethAngle = 360/30;
                 if (i % 2 == 0) {
                     float x = cos(radians(i*teethAngle)) * 40;
                     float y = sin(radians(i*teethAngle)) * 40;
                     vertex(x, y);
                 } else {
                     float teethSize = random(20, 22);
                     float x = cos(radians(i*teethAngle)) * teethSize;
                     float y = sin(radians(i*teethAngle)) * teethSize;
                     vertex(x, y);
                 }
             }
             endShape(CLOSE);
     */
        }
    }
    
    /*-----------------------------------------------
    Autor: Alba G. Corral 
    Fecha : 10.03.2009
    Titulo: black tentacle monster remix
    Descripcion: una version de un mounstro de la web processing monsters
    
    http://www.rmx.cz/monsters/
    ---------------------------------------------------
    
    */
    
    //import processing.opengl.*;
    //se puede utilizar la libreria opengl para darle otro aspecto a las lineas
    Monster monster;
    boolean saveOne = false;
    
    void setup()
    {
      size(550, 700,P3D);
      noStroke();
      smooth();
      monster = new Monster(360, 10);
    
    
    
    }
    
    void draw()
    {
      smooth();
      background(255);
      translate(width/2, height/2);
    
      monster.draw();
    
      if (saveOne) {
        saveFrame("renders/blackmonster-#######.png");
        saveOne = false;
      }
    }
    
    void keyPressed()
    {
      if (key == 's') {
        saveOne = true;
      }
    }
    
    

    code

    tweaks (0)

    about this sketch

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

    license

    advertisement

    Alba G. Corral

    black tentacle moster remix

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

    Autor: Alba G. Corral
    Fecha : 10.03.2009, barcelona
    Titulo: black tentacle monster remix
    Descripcion: una version de un mounstro de la web processing monsters
    http://www.rmx.cz/monsters/
    ---------------------------------------------------

    subpixel
    11 Mar 2009
    It's coming to eat me! :o)
    Mariano Crivelli
    12 Mar 2009
    muy bueno :D
    Ale
    15 Oct 2011
    Muy chulo, y con un poquito de interactividad estaría mejor todavía...
    ^-^
    You need to login/register to comment.