//Snow Storm// //25. Dec. 2006 by Huang, Yung-Chieh// //----------------START OF DESCRIPTION OF CLASS SNOW----------------// class Snow { float Radius; //radius of snowflake float PosX; //x position of snowflake float PosY; //y position of snowflake float VelX; //x velocity of snowflake float VelY; //y velocity of snowflake float WindX; //x intensity of wind float WindY; //y intensity of wind Snow(float r, float px, float py, float vx, float vy, float wx, float wy) { Radius = r; //variable for radius PosX = px; //variable for x position PosY = py; //variable for y position VelX = vx; //variable for x velocity VelY = vy; //variable for y velocity WindX = wx; //variable for x intensity of wind WindY = wy; //variable for y intensity of wind } void fall(float wx, float wy) //calculate the snowflake position { WindX = wx; //variable for x intensity of wind WindY = wy; //variable for y intensity of wind draw(); if(PosX > width){ PosX = 0; } else if (PosX < 0){ PosX = width; } if(PosY > height){ PosY = 0; } else if (PosY < 0){ PosY = height; } PosX += VelX*(Radius/3)*random(-1, 1) + WindX; PosY += VelY*(Radius/3) + WindY; } void draw() //draw the snowflake { ellipseMode(CENTER); noStroke(); fill(255,150); ellipse(PosX, PosY, Radius*2, Radius*2); } } //----------------END OF DESCRIPTION OF CLASS SNOW----------------// //----------------START OF MAIN TASK------------------------------// int amount = 250; //density of snowflakes Snow[] mySnows = new Snow[amount]; //build snow array float wx; float wy; int value = 0; // wind switch void setup(){ size(500, 500); //set window size for(int i=0; i