Powered By Blogger

Monday 11 April 2011

Found new code for moving clouds!

Funatti has a code that explores a cloud scene that is very effective and I would like to focus on his code due to the way he creates movement of cloud forms across the screen. You can find the original code HERE.

Below is part of Funatti's code that explores a 'class' - A class is a composite of data and methods (functions) which may be instantiated as objects. As I found out through the Processing Reference, and Luke & Ben.

class Particle{
    float x;
    float y;
    int s;
    
     Particle(float _x, float _y,  int _s){
        x = _x;
        y = _y;
        s = _s;
    }
    
    void move(){
        x += random(6);
        y += random(5) - 2;
        
        if(x<0) x = width;
        if(x>width) x = 0;
        if(y<0) y = height;
        if(y>height) y = 0;
    }
    
   void draw(){
        fill(255,15);
        noStroke();
        ellipse(x,y,s,s);
    }
}



The above relates to other parts of the code that have created "particles" and array's . However what I am interested in is the void move() function. As this is where the movement of the circles across the screen comes into play. Note being: the class function will be helpful in the interaction of the mouse with the circles and their radius length. As I will be able to create another function within the particle class labelled "void mouse()" which will describe the interaction of the mouse with the clouds (ellipses) being drawn and moved.

No comments:

Post a Comment